0
0
Dockerdevops~15 mins

Docker logging drivers - Mini Project: Build & Apply

Choose your learning style9 modes available
Docker Logging Drivers Setup
📖 Scenario: You are managing a Docker container for a simple web application. You want to control how Docker handles the logs generated by this container.
🎯 Goal: Learn how to configure Docker logging drivers for a container and verify the logging setup.
📋 What You'll Learn
Create a Docker container running the nginx image with a specific name
Set a logging driver configuration variable
Run the container with the logging driver option
Check the container's logging driver configuration
💡 Why This Matters
🌍 Real World
In real projects, controlling Docker logging helps manage log storage, format, and integration with monitoring tools.
💼 Career
Understanding Docker logging drivers is important for DevOps roles to ensure efficient log management and troubleshooting.
Progress0 / 4 steps
1
Create a Docker container named mynginx using the nginx image
Run the command to create and start a Docker container named mynginx using the nginx image in detached mode.
Docker
Need a hint?

Use docker run -d --name mynginx nginx to start the container in the background.

2
Set a variable LOG_DRIVER to json-file
Create a shell variable called LOG_DRIVER and set its value to json-file.
Docker
Need a hint?

Use LOG_DRIVER=json-file to set the variable.

3
Run a new container named mynginx2 using the nginx image with the logging driver set to $LOG_DRIVER
Run a Docker container named mynginx2 using the nginx image in detached mode, and set the logging driver to the value of the LOG_DRIVER variable using the --log-driver option.
Docker
Need a hint?

Use docker run -d --name mynginx2 --log-driver $LOG_DRIVER nginx.

4
Check the logging driver of the container mynginx2
Run the command to inspect the container mynginx2 and display only the logging driver used by this container.
Docker
Need a hint?

Use docker inspect --format='{{.HostConfig.LogConfig.Type}}' mynginx2 to see the logging driver.