Docker image deployment in VPC

Posted August 29, 2021 310 views
DockerFirewallDeploymentDigitalOcean VPC

I have my database in VPC and I want to deploy an APP inside the VPC via docker image which can connect to the database in the VPC network, but it should be able to listen to public traffic on http port 80. Can someone please guide on how to do it with digital ocean. I am pretty new to cloud deployments. Thanks

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 there,

I think that, in your case, one approach you could use the --network host flag so that your Docker container networking uses the host network, as per the documentation here:

The command that you could use would look like this:

docker run --rm -d --network host --name my_nginx nginx

That way your container will have access to both the VPC network and the public network.

Hope that this helps.