How to view docker nginx container through domain name?

Hi guys,

As the question states I would like for when users browse to my domain name they see my nginx container. Currently I can view the container (default nginx) when I browse to my droplets ip but not through the domain name. I know my domain name is pointing to my droplet correctly since performing tracerts/pings result in a connection to my droplets ip.

My setup has been this:

  1. launch ubuntu droplet
  2. install docker
  3. pull nginx image and run it with -p 80:80

runing docker ps results in: a7d45cc55a85 nginx “nginx -g 'daemon of…” 8 minutes ago Up 8 minutes>80/tcp

This has resulted in the display of the ‘Welcome to nginx’ page when I browse to my server ip, but when I browse to my domain I get ERR_CONNECTION_REFUSED, “This site can’t be reached”.

Any help would be much appreciated.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

So I actually figured it out eventually. I have a .dev domain, and what was happening is every time I would go to it would always attempt to go to so I solved the problem by adding an ssl certificate to my nginx config.