How can I connect a docker container to two docker networks that I have created

0 votes

Hi Guys,

I am working on a project. For that I used Docker container. By default every docker container uses bridge driver for networking. Can I use more than one driver in my docker container?

Thank You

Mar 23, 2020 in Docker by akhtar
• 38,260 points
10,870 views

1 answer to this question.

0 votes

Hi@akhtar,

It's correct that the network argument of the docker run command only supports one network. But we can connect another network card to our container.

Example:

create multiple networks

  1. docker network create --driver bridge net1
  2. docker network create --driver host net2

run the container using the initial network and connect it to the other network.

  1. docker run  -it --name Ubuntu --network net1 Ubuntu
  2. docker network connect net2 Ubuntu

Hope this will help you.

Thank You

answered Mar 23, 2020 by MD
• 95,460 points
I think docker does not support creating multiple instances of host network driver, hence the command for net2 is failing. The point i would like to clarify here is that a container could be able to attach to multiple user defined networks.

Related Questions In Docker

+1 vote
0 answers

How can I map a docker location to my Jenkins workspace so that I can use the files in my Jenkins

Hey guys, I was trying to execute few ...READ MORE

Feb 25, 2020 in Docker by dineshkumar
• 130 points
4,948 views
0 votes
2 answers

How to edit file after I shell to a docker container?

You can even install it using a ...READ MORE

answered Apr 23, 2019 in Docker by Ashish
17,869 views
0 votes
1 answer

Docker: Add a restart policy to a container that was already created

In recent versions of docker (as of ...READ MORE

answered Jul 30, 2018 in Docker by Kalgi
• 52,350 points
1,594 views
+1 vote
2 answers

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 28, 2018 in Docker by Damon Salvatore
• 5,980 points
28,602 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,730 views
+15 votes
19 answers

How can I run a ‘docker exec’ command inside a docker container?

you can run any command in a ...READ MORE

answered Dec 10, 2018 in Docker by Pramiti
1,229,685 views
0 votes
1 answer

How can I install systemctl tool in Docker container?

Hi@akhtar, In docker container if you want to ...READ MORE

answered Feb 5, 2020 in Docker by MD
• 95,460 points
20,255 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP