Container Network LAB
Table of contents
LAB 1. Docker0 network
Configure containers and networks like below
Required Satisfaction Conditions
- Container image: busybox:latest
- Connet to inside with creating a container
- CMD [“sh”]
- Check those’s IP
Buiding Step
- C1
$ docker run –name C1 -d -it –rm busybox:latest
- C2
$ docker run –name C2 -d -it –rm busybox:latest
IP check
C1
$ docker attach C1 / # ifconfigC2
$ docker attach C2 / # ifconfig
Create container with reference to the following conditions
- Container name: web
- Container image: nginx:latest
- Port-forwarding: Port 80
- Background-Activating
Building step
- $ docker run -d –name web -p 80:80 nginx:latest
- -d : background-activating
- –name: container name
- -p : port-forwarding
Q. How to know container web’s IP
- $ docker inspect web
- You can check docker0’s role as a gateway in the container network.
LAB 2. Port-Forwarding
O. Run 3 containers by the following below condition.
Web1
- Container image: nginx:latest - Container name: web1
- Background-Activating
- Insert command : -p 80:80Web2
- Container image: nginx:latest - Container name: web2
- Background-Activating
- Insert : -p 80Web3
- Container image: nginx:latest - Container name: web3
- Background-Activating
- Insert : -P
A. Building Step
- Web1
$ docker run –name web1 -d -p 80:80 nginx:latest - Web2
$ docker run –name web2 -d -p 80 nginx:latest - web3
$ docker run –name web3 -d -P
LAB 3. Creating User-Defined Network
Q. Create a network for use at containers by following the below conditions
- subnet: 192.168.1.0/24
- gateway: 192.168.1.254
- network name : cloudnet
A. Building step
```
$ docker network create --driver bridge \
--subnet 192.168.1.0/24 \
--gateway 192.168.1.254 \
```