filmov
tv
The Docker Bridge Network - Docker networks part 1
Показать описание
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 :
Комментарии