Introduction
Imagine you are in the ancient grasslands of Gelasian, where wild horses roam freely and the bond between a horse tamer and the untamed beasts is vital for survival. Your role is the wild horse tamer, tasked with the challenge of utilizing Docker to manage Docker containers efficiently in this vast landscape.
Mastering Container Creation
In this step, you will learn the basics of creating and managing Docker containers to survive in the wild grasslands.
Tasks
- Create an Nginx container named
mynginxand ensure it is running successfully. - Launch an Alpine container and verify its status.
- Deploy an Ubuntu container with a specific volume attached (mounting the host's
~/projectto the container's/app).
Requirements
- You must conduct all operations within the
/home/labex/projectdirectory. - Utilize the following commands:
- For creating containers:
docker run - For checking container status:
docker ps - For attaching a volume:
docker run -v
- For creating containers:
Example
After completing the tasks, the output of docker ps should display the running containers, including relevant information like container ID, image, and status.
labex:~/ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1983f85f03d4 ubuntu "sleep 3600" 22 seconds ago Up 21 seconds ubuntu_container
4231996cae33 alpine "sleep 3600" 2 minutes ago Up 2 minutes alpine_container
519eadd3ced5 nginx "/docker-entrypoint.…" 2 minutes ago Up 2 minutes 80/tcp mynginx
Container Networking and Communication
In this step, you will delve into the world of container networking and communication to establish seamless connectivity across the grasslands.
Tasks
- Create a custom network named
mynetworkfor the containers. - Deploy a Alpine container named
myalpineon the custom network and ensure it can communicate with other containers namedmypythonbased on the Python image in the same network.
Requirements
- All operations must remain within the
/home/labex/projectdirectory. - Utilize the following commands:
- For creating a custom network:
docker network create - For attaching containers to a network:
docker network connect
- For creating a custom network:
Example
Upon completion of the tasks, the custom network should be visible when executing docker network ls, and the Python container should successfully communicate with other containers within the network.
See the network:
labex:~/ $ docker network ls
NETWORK ID NAME DRIVER SCOPE
1a367e6cc4e5 bridge bridge local
91199fc6ad2e host host local
32e2857073a9 minikube bridge local
92d3b71b7efd mynetwork bridge local
1078d2c781b6 none null local
See the containers connection by ping:
labex:~/ $ docker exec myalpine ping mypython
PING mypython (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.153 ms
64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.072 ms
64 bytes from 172.18.0.3: seq=2 ttl=64 time=0.069 ms
Summary
In this challenge, you will take on the role of a wild horse tamer in the ancient grasslands, mastering the art of managing Docker containers. By completing the tasks and understanding the solutions, you will gain essential skills in Docker container management and networking, essential for surviving in the untamed world of Docker.



