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!
Accepted Answer
Hey there 👋
Great question! The easiest way to expose your Docker container is by using the -p
flag when running your container. For example:
docker run -d -p 80:80 your-image
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!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.