These exercises will help you apply the core Docker concepts and commands covered in the theory section. They focus on installing Docker, running basic containers, and mastering essential CLI commands.
Verify your installation by running:
docker --version
docker info
sudo
by adding your user to the docker
group if needed.Run the simplest Docker container to verify your Docker setup:
docker run hello-world
Observe the output and describe the steps Docker performs (image pull, container creation, execution).
Start an Nginx web server container in detached mode, mapping port 8080 on your host to port 80 in the container:
docker run -d -p 8080:80 nginx
Check that the container is running with:
docker ps
Inspect the container logs using:
docker logs <container_id>
Access the running Nginx container’s shell:
docker exec -it <container_id> sh
Explore the container’s filesystem, for example:
ls /usr/share/nginx/html
Exit the container shell by typing exit
.
Stop the running Nginx container:
docker stop <container_id>
Remove the stopped container:
docker rm <container_id>
List all containers, including stopped ones:
docker ps -a
Start an interactive Alpine Linux container:
docker run -it alpine sh
Summary:
These exercises provide hands-on experience with Docker installation, container creation and management, and interaction with running containers — building a solid foundation for the rest of the course.