Creando redes
Crear red de imagen
Dockerfile editado
# editar contenido Dockerfile
FROM ubuntu
RUN apt-get update && apt-get install net-tools iputils-ping -y
# generar imagen usando Dockerfile
docker image build -t ubuntu-tools .
# salida
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM ubuntu
---> 72300a873c2c
Step 2/2 : RUN apt-get update && apt-get install net-tools iputils-ping -y
---> Running in a24f7101eaef
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
...
Fetched 17.6 MB in 2min 6s (139 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libcap2 libcap2-bin libidn11 libpam-cap
The following NEW packages will be installed:
iputils-ping libcap2 libcap2-bin libidn11 libpam-cap net-tools
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 336 kB of archives.
After this operation, 1339 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libcap2 amd64 1:2.25-1.2 [13.0 kB]
...
debconf: delaying package configuration, since apt-utils is not installed
Fetched 336 kB in 3s (97.5 kB/s)
Selecting previously unselected package libcap2:amd64.
(Reading database ... 4046 files and directories currently installed.)
Preparing to unpack .../0-libcap2_1%3a2.25-1.2_amd64.deb ...
Unpacking libcap2:amd64 (1:2.25-1.2) ...
Selecting previously unselected package libidn11:amd64.
Preparing to unpack .../1-libidn11_1.33-2.1ubuntu1.2_amd64.deb ...
Unpacking libidn11:amd64 (1.33-2.1ubuntu1.2) ...
Selecting previously unselected package iputils-ping.
Preparing to unpack .../2-iputils-ping_3%3a20161105-1ubuntu3_amd64.deb ...
Unpacking iputils-ping (3:20161105-1ubuntu3) ...
Selecting previously unselected package libcap2-bin.
Preparing to unpack .../3-libcap2-bin_1%3a2.25-1.2_amd64.deb ...
Unpacking libcap2-bin (1:2.25-1.2) ...
Selecting previously unselected package libpam-cap:amd64.
Preparing to unpack .../4-libpam-cap_1%3a2.25-1.2_amd64.deb ...
Unpacking libpam-cap:amd64 (1:2.25-1.2) ...
Selecting previously unselected package net-tools.
Preparing to unpack .../5-net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
Setting up libcap2:amd64 (1:2.25-1.2) ...
Setting up net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
Setting up libidn11:amd64 (1.33-2.1ubuntu1.2) ...
Setting up iputils-ping (3:20161105-1ubuntu3) ...
Setting up libpam-cap:amd64 (1:2.25-1.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
Setting up libcap2-bin (1:2.25-1.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Removing intermediate container a24f7101eaef
---> 6c0352412a2f
Successfully built 6c0352412a2f
Successfully tagged ubuntu-tools:latest
# crear nueva red a usar al generar contenedor de la imagen
# ver ayuda
docker network create --help
Usage: docker network create [OPTIONS] NETWORK
Create a network
Options:
--attachable Enable manual container attachment
--aux-address map Auxiliary IPv4 or IPv6 addresses used by Network driver (default map[])
--config-from string The network from which copying the configuration
--config-only Create a configuration only network
-d, --driver string Driver to manage the Network (default "bridge")
--gateway strings IPv4 or IPv6 Gateway for the master subnet
--ingress Create swarm routing-mesh network
--internal Restrict external access to the network
--ip-range strings Allocate container ip from a sub-range
--ipam-driver string IP Address Management Driver (default "default")
--ipam-opt map Set IPAM driver specific options (default map[])
--ipv6 Enable IPv6 networking
--label list Set metadata on a network
-o, --opt map Set driver specific options (default map[])
--scope string Control the networks scope
--subnet strings Subnet in CIDR format that represents a network segment
# sentencia de comando para crear red con flag -d (driver de red)
docker network create -d bridge br0
8e9c2463ce18fa0e9e653e46ed728f031205d94973d8a428953cd1c606099abe
# inspeccionar nueva red
docker network inspect br0
[
{
"Name": "br0",
"Id": "8e9c2463ce18fa0e9e653e46ed728f031205d94973d8a428953cd1c606099abe",
"Created": "2020-03-09T20:38:31.624165412-06:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.22.0.0/16",
"Gateway": "172.22.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]Agregar contenedor a red de imagen previa
Última actualización
¿Te fue útil?