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,230 points

1 answer to this question.

0 votes


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.


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,320 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
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
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,370 points
+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
+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,140 points
+8 votes
19 answers
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,320 points