Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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:

container_commands:

  00-test_command:

    command: bundle exec thin --net=host

  01-networking-fix:

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

1 Answer

0 votes
by (18.2k points)

Try the following commands:

container_commands:

  00_fix_networking:

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

  01_fix_docker_ip:

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

These commands will fix your upstart script

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...