Medieval Farmers Docker Adventure

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will be transported to a medieval city where a farmer needs your assistance. The city is bustling with activity, and the farmer needs a way to transport his goods efficiently to various parts of the city. Your goal is to attach to the farmer's transport container and oversee the logistics of moving the goods to different locations within the city.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("`Docker`")) -.-> docker/ContainerOperationsGroup(["`Container Operations`"]) docker/ContainerOperationsGroup -.-> docker/attach("`Attach to Container`") docker/ContainerOperationsGroup -.-> docker/exec("`Execute Command in Container`") subgraph Lab Skills docker/attach -.-> lab-271453{{"`Medieval Farmers Docker Adventure`"}} docker/exec -.-> lab-271453{{"`Medieval Farmers Docker Adventure`"}} end

Create a Docker Container

In this step, you will create a Docker container to represent the farmer's transport container.

## Create a new Docker container
docker run --name transport-container -d alpine tail -f /dev/null

Attach to the Container

Now, attach to the transport container to observe the logistics.

## Attach to the container
docker attach transport-container

Transfer Goods

In this step, use the following command in another terminal to take an interactive shell to the container, and simulate the transfer of goods inside the attached container.

docker exec -it transport-container sh
## create a hello.py file
echo "print('Hello Docker')" > hello.py
## Inside the attached container, move the hello.py to different locations
mv hello.py /var

Summary

In this lab, you learned how to use the Docker attach command to interact with a running container. By simulating a medieval city scenario, you were able to grasp the concept of attaching to a container and executing operations within it. This hands-on experience provides a practical understanding of container management and attachment techniques.

Other Docker Tutorials you may like