I’m running a Docker container on my DigitalOcean Droplet and I want to expose it to the internet so I can access it via my domain or public IP.
What’s the proper way to do this? Should I use -p
flags or set up Nginx as a reverse proxy?
Just want to make sure I’m doing it the right way.
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!
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.
Hey there 👋
Great question! The easiest way to expose your Docker container is by using the
-p
flag when running your container. For example:That maps port 80 on your Droplet to port 80 in your container, so you can access it via your Droplet’s public IP.
If you want to expose multiple services or use a domain name, setting up Nginx as a reverse proxy is a solid option, gives you more flexibility and makes it easier to manage multiple containers behind one domain.
Check out this video here for more details:
Also, if you’re just getting started with Docker, feel free to check out this free eBook here: 👉 Introduction to Docker Free eBook
Hope that helps!
- Bobby
Heya, @6e913a726e3b411f8664012c7eb00c
Really good question here. The proper way depends on your use case — but generally, for production or multi-app setups, you should use NGINX as a reverse proxy.
Hope that this helps!