0
0
Dockerdevops~30 mins

Docker engine and runtime - Mini Project: Build & Apply

Choose your learning style9 modes available
Docker Engine and Runtime Basics
๐Ÿ“– Scenario: You are starting to learn Docker, a tool that helps you run applications inside small, isolated containers. These containers use the Docker Engine and runtime to work smoothly on your computer.Imagine you want to run a simple web server inside a Docker container to understand how Docker Engine manages containers and images.
๐ŸŽฏ Goal: Build a simple Docker setup where you create a Dockerfile, configure a basic web server image, run a container from it, and check the container status using Docker Engine commands.
๐Ÿ“‹ What You'll Learn
Create a Dockerfile with a base image and a command to run a web server
Add a configuration variable for the container name
Write the Docker command to build the image and run the container with the specified name
Use Docker Engine commands to list running containers and show the container logs
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Docker Engine and runtime are used daily by developers and system administrators to package applications and run them consistently across different computers.
๐Ÿ’ผ Career
Understanding Docker basics is essential for roles like DevOps engineer, system administrator, and backend developer to manage application deployment and scaling.
Progress0 / 4 steps
1
Create a Dockerfile with a base image and command
Create a file named Dockerfile with these exact contents:
FROM nginx:alpine
CMD ["nginx", "-g", "daemon off;"]
Docker
Need a hint?

The Dockerfile must start with FROM nginx:alpine and use CMD ["nginx", "-g", "daemon off;"] to keep the server running.

2
Add a container name variable
Create a variable called container_name and set it to the string my_nginx.
Docker
Need a hint?

Just write container_name = "my_nginx" below the Dockerfile content.

3
Build the Docker image and run the container
Write the exact Docker commands to build an image named nginx_image from the Dockerfile and run a container with the name stored in container_name in detached mode.
Docker
Need a hint?

Use docker build -t nginx_image . to build and docker run -d --name my_nginx nginx_image to run the container.

4
Check running containers and view logs
Write the Docker commands to list all running containers and then show the logs of the container named my_nginx.
Docker
Need a hint?

Use docker ps to list running containers and docker logs my_nginx to see the container logs.