Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (12.9k points)

Here's the thing, I need to tell Docker to not containerize the container’s networking, because it needs to connect to a MongoDB that is inside a VPN (enterprise private DB).

There is a Docker command that let's me do exactly that: --net=host. Reference here.

So, for example, when running the container on my local machine, I will do something like:

docker run --rm -it --net=host [image-name]:[version] bash -il

And that command will do the trick. Thanks to that, I can connect to the "private" MongoDB.

So, my question is: Is there a way customize the docker run command of a Single Docker Environment on Elastic Beanstalk so I can add the --net=host?

I have tried using the container_commands into the config.yml file to add that instruction there, but I don't think that does what I need, here is a snippet:



    command: bundle exec thin --net=host


    command: "docker run --rm -it --net=host [image-name]:[version] bash -il"

1 Answer

0 votes
by (18.2k points)

Try the following commands:



    command: sed -i 's/docker run -d/docker run --net=host -d/' /opt/elasticbeanstalk/hooks/appdeploy/enact/


    command: sed -i 's/server $EB_CONFIG_NGINX_UPSTREAM_IP/server localhost/' /opt/elasticbeanstalk/hooks/appdeploy/enact/

These commands will fix your upstart script

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories