I have an active docker container listening to port 4000. Following this tutorial https://axelclark.com/deploy-phoenix-to-digital-ocean/ 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

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.

×
Submit an Answer
1 answer

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:

https://docs.docker.com/config/containers/container-networking/