Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
6 views
in DevOps and Agile by (2.3k points)
edited by

how to create a network in docker?

1 Answer

0 votes
by (6.9k points)

Now there are different types of networks that you can create and use, they are:

Bridge Network

Overlay Network

Macvlan Network

Host Network

These are the commands to create them:

Bridge Network:

$ sudo docker network create --driver bridge <name_of_network>

Overlay Network:

$ sudo docker network create --driver overlay <name_of_network>

Macvlan Network: ( here you will need to mention the parent, subnet and gateway )

$ sudo docker network create -d macvlan \
  --subnet=172.16.86.0/24 \
  --gateway=172.16.86.1 \
  -o parent=eth0 pub_net

Host Network: ( this is used while creating a container )

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

Hope this helped :)


New to docker ? need help? try out docker training course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...