The Docker Bridge Network - Docker networks part 1

preview_player
Показать описание

Many thanks for your replies to the poll - your wish is my command and here is the episode on docker networks. As there is so much to tell about docker networks, we will talk about Bridges in this episode. In the next episode we will talk about the host and macvlan network. Networking with Docker, docker bridge networks and docker host and macvlan networks as well as docker-compose are subjects of this series. We will define the networks in the Portainer Networking section

0:00 Intro
1:23 TLDR / TLDW / Chapters
1:42 Describing the setup nginxdemos/hello
2:08 What do we need ?
3:10 Pull the image
4:00 examining the container
5:33 IP Connectivity on the bridge
7:30 Network access
7:55 Hostnames
8:33 Name resolution default bridge
9:22 Port mapping
10:15 The bridge is NAT-ed
11:10 user defined bridges
13:26 Summary bridges
14:00 automate with docker-compose
18:03 Outlook, wrap-up

Here's the list of the commands / steps used in the video:

(on a Pi it may be called docker-ce)

One liner to start portainer:

(In portainer, click on "Networks" on the left, you'll see the networks)
(on the command line)

docker network ls

(Pulling the image and running it)
docker run -d nginxdemos/hello

(in Portainer, Containers Menu, then "Add Container")
(Finding the IP address - click on the container name in Portainer)

Default Bridge IP is usually 172.17.0.0/24, the docker host is 172.17.0.1

(Click on the container name and Select "Duplicate/Edit" to clone it)
In order to execute shell (/bin/ash) on the command line

docker exec -it CONTAINERNAME /bin/ash

Commands I type INSIDE the containers:

ip addr
hostname
ip route
ping 172.17.0.x
ping 8.8.8.8

Create the image with port mapping and container name:

docker run -d --name nginx1 -p 81:80 nginxdemos/hello
docker run -d --name nginx2 -p 82:80 nginxdemos/hello
(now you can browse to localhost:81 or localhost:82)

Create the bridge network:

docker network create -d bridge --subnet 172.172.0.0/24 --gateway 172.172.0.1 --ip-range 172.172.0.128/25 --attachable marcsbridge

In order to run the containers on the user defined bridge:

docker run -d --name nginx1 -p 81:80 --network marcsbridge nginxdemos/hello
docker run -d --name nginx2 -p 82:80 --network marcsbridge nginxdemos/hello

Install docker-compose:

sudo apt install docker-compose

(Download the .deb for Ubuntu/Debian, you will then find the File in your Downloads directory. You can then install it with):

sudo dpkg -i (Filename)
for example

In order to have the docker-compose extension in Visual Studio Code, select View-Extensions. There are many extensions available, e.g. "Docker Extension Pack" or "Docker Explorer" by Jun Han, or "Docker" by Microsoft or "Docker Compose" by p1c2u

Command line compose up :

Рекомендации по теме
Комментарии
Автор

I will join the chorus of voices who have stumbled in the dark until discovering your videos. Well done, thank you very much for quality content. I like the pace and the hands-on approach.

jacksonmacd
Автор

After watching other explanations on Docker Bridge Networks and not understanding, this video explains it perfectly !
Excellent

johnu
Автор

This 2 part tutorial are the first of your videos I watch. I have been self-training in docker for the last few weeks and these are the best introduction to the topic of docker networking I have found by far. Love the hands on approach with exercises that really help get the notions clarified. Bravo! subscribed now.

Автор

This is the best docker networking tutorial available in the web. I became a big fan of yours.

krishnapanjiyar
Автор

Incredibly clear information on docker networks. Keep up the great work!

gotelldonn
Автор

I've just started to learn Docker and used this tutorial on an Ubuntu 21.04 VM running on ESXi7. I couldn't believe how much I learned in a very short time!

Thanks, Marc.

unmesh
Автор

So impressed of your way of explain things. Keep up the good work!

ivanhansson
Автор

I've just found this channel and I really enjoy every damn video.
Thank you so much!

A firmly handshake from Spain! 🇪🇸

JoaquinVacas
Автор

Thank you. I have been wondering how networking worked in Docker. I learned so much.

MikePacholik
Автор

really enjoyed watching this one. having spent a couple of weeks clicking around in portainer and not being quite sure how the interface & the options dovetail with docker input on the CLI or using docker-compose, this clearly explained and engaging video has helped tremendously to demystify. And i also learned some of the fundamentals of docker networking also.

when at first a topic seems unfathomable, there is a sudden lightbulb-moment when it all begins to make sense. the demystification process (the rolling back of the fog) is to a greater extent attributable of the abilities of teacher. i'm guessing you are a teacher by profession (?). Many thanks Marc for the time and effort you have put into sharing your knowledge. without hesitation, i have subscribed.

daysiewaysie
Автор

Fantastic Marc….. going to have a play with this, it’s been one of those “dark arts” thank you.

tonybell
Автор

Awesome! I have never come across such a clear explanation on how dockers and docker networks work. Thank you very much

jeytis
Автор

Very informative, thank you. There are far too many videos out there that are just like "use host" or "use bridge" and never explain why. Then if things don't work you're left on your own to figure it out with no real understanding of what is going on.

leemiller
Автор

Amazing tutorial!! I loved the comparison between portainer and the comand line!! Now I have the networking clear!! Thank you

cursoderobotica
Автор

Great video, cannot wait for the next on macvlan!

Alt
Автор

You are the best instructor! thanx for you work!

SenoClub
Автор

This was very instructive and easy to follow. Thank you.

kaybax
Автор

Excellent and to the point, I never used portainer before seems to be a good alternative to the CLI, very good to know and to have it in the bag of management tools. Looking forward to part 2, thank you for the awesome content Marc.

jairunet
Автор

Thank you Marc - very informative and well-presented.

djjmahon
Автор

Just waiting for your next episode on this. I love your work Marc 👍👍👍👍

dharunpazhanivel