How to set droplet listen to port 4000 /with docker/

I have an active docker container listening to port 4000. Following this tutorial everything seems right, but obviously the droplet is not listening to this port, cause there is no output on the net with the IP. How do I set my droplet listen to certain port?

$ docker ps
(...)    STATUS        PORTS       (...)
(...)  Up 18 hours    4000/tcp     (...)
$ ping 12.345.678.910
64 bytes from 12.345.678.910: icmp_seq=1 ttl=55 time=38.6 ms
64 bytes from 12.345.678.910: icmp_seq=2 ttl=55 time=37.8 ms
64 bytes from 12.345.678.910: icmp_seq=3 ttl=55 time=36.7 ms

Best Regards, ykostov


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @ykostov,

By default, when you create or run a container using docker create or docker run, it does not publish any of its ports to the outside world. To make a port available to services outside of Docker, or to Docker containers which are not connected to the container’s network, use the --publish or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world. Here are some examples.

I’ll recommend checking the Docker docs here for more information: