Question

How do I expose a Docker container to the internet on my Droplet?

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.


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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 24, 2025
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

alexdo
Site Moderator
Site Moderator badge
March 24, 2025

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!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.