Lab 3.6: User-Defined Bridge Network

1. Membuat bridge network alpine-net

sudo docker network create --driver bridge alpine-net

2. Tampilkan daftar network. [screenshot-3-6-2]

sudo docker network ls

3. Tampilkan detil network alpine-net

sudo docker network inspect alpine-net

4. Buat 3 container: container alpine1 terhubung ke network default bridge, container alpine2 terhubung ke network alpine-net dan container alpine3 terhubung ke kedua network default bridge dan alpine-net

sudo docker run -dit --name alpine1 alpine ash
sudo docker run -dit --name alpine2 --network alpine-net alpine ash
sudo docker run -dit --name alpine3 alpine ash
sudo docker network connect alpine-net alpine3
sudo docker container ls

5. Tampilkan detil network bridge dan alpine-net

sudo docker network inspect bridge
sudo docker network inspect alpine-net

6. Masuk ke container alpine3 dan uji ping ke alamat ip alpine1 dan ke nama container alpine1 dan alpine2. [screenshot-3-6-6]

sudo docker attach alpine3
ping -c 3 172.17.YYY.YYY
ping -c 3 alpine1
ping -c 3 alpine2

7. Masuk ke container alpine2 dan uji ping ke alamat ip container alpine1 (gagal karena beda bridge network dan beda subnet) dan ke internet (sukses).. [screenshot-3-6-7]

sudo docker attach alpine2
ping -c 3 172.17.YYY.YYY
ping -c 3 8.8.8.8

8. Hapus semua container dan network alpine-net

sudo docker container rm -f alpine1 alpine2 alpine3
sudo docker network rm alpine-net
Daftar Materi