Bird
Raised Fist0
Dockerdevops~20 mins

Centralized logging setup in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Centralized Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Docker logging driver output
You run a Docker container with the command:
docker run --log-driver=json-file --name test-container alpine echo hello

What will be the output of docker logs test-container?
Ahello
BNo output, because json-file driver does not store logs
CError: logging driver not supported
DContainer logs are empty
Attempts:
2 left
💡 Hint
The json-file logging driver stores container stdout and stderr logs locally.
❓ Configuration
intermediate
2:00remaining
Configure Docker to use syslog logging driver
Which Docker daemon configuration snippet correctly sets the default logging driver to syslog?
A
{
  "log_driver": "syslog"
}
B
{
  "logging-driver": "syslog"
}
C
{
  "log-driver": "syslog"
}
D
{
  "logdriver": "syslog"
}
Attempts:
2 left
💡 Hint
Docker daemon config uses kebab-case keys with hyphens.
🔀 Workflow
advanced
2:00remaining
Centralized logging with ELK stack and Docker
You want to send Docker container logs to an ELK (Elasticsearch, Logstash, Kibana) stack. Which logging driver should you configure on your containers to send logs directly to Logstash over TCP?
Ajson-file
Bsyslog
Cfluentd
Dgelf
Attempts:
2 left
💡 Hint
GELF is a logging format supported by Logstash for structured logs over TCP/UDP.
❓ Troubleshoot
advanced
2:00remaining
Docker logs missing after configuring syslog driver
After configuring Docker containers to use the syslog logging driver, you notice docker logs shows no output. Why does this happen?
ASyslog driver sends logs outside Docker, so 'docker logs' cannot access them
BSyslog driver disables container stdout and stderr
CDocker daemon crashed and lost logs
DThe container did not produce any logs
Attempts:
2 left
💡 Hint
Syslog driver forwards logs to the host syslog service, not stored in Docker's local log files.
✅ Best Practice
expert
3:00remaining
Best practice for centralized logging in a multi-host Docker swarm
In a Docker Swarm with multiple hosts, what is the best practice to collect and centralize logs from all containers across hosts?
AConfigure each container to use the json-file driver and manually copy log files from each host
BUse a centralized logging agent like Fluentd or Logstash on each host to collect container logs and forward them to a central server
CUse the default Docker logging driver and rely on 'docker logs' command on each host separately
DDisable logging to improve performance and avoid log storage
Attempts:
2 left
💡 Hint
Centralized logging agents can collect logs from multiple sources and forward them reliably.

Practice

(1/5)
1. What is the main purpose of using a centralized logging setup in Docker?
easy
A. To reduce the size of container images
B. To increase container startup speed
C. To collect logs from multiple containers in one place for easier monitoring
D. To automatically restart containers on failure

Solution

  1. Step 1: Understand centralized logging concept

    Centralized logging means gathering logs from many containers into a single location.
  2. Step 2: Identify the benefit

    This helps in easier monitoring and troubleshooting by having all logs accessible in one place.
  3. Final Answer:

    To collect logs from multiple containers in one place for easier monitoring -> Option C
  4. Quick Check:

    Centralized logging = collect logs centrally [OK]
Hint: Centralized logging means one place for all container logs [OK]
Common Mistakes:
  • Confusing logging with container performance
  • Thinking it reduces image size
  • Assuming it restarts containers automatically
2. Which Docker command option correctly sets the log driver to Fluentd for a container?
easy
A. docker run --log-driver fluentd myimage
B. docker run --log-driver=fluentd myimage
C. docker run --log-driver:fluentd myimage
D. docker run --logdriver=fluentd myimage

Solution

  1. Step 1: Recall Docker log driver syntax

    The correct syntax uses double dashes and equals sign: --log-driver=drivername
  2. Step 2: Match the option

    docker run --log-driver=fluentd myimage uses --log-driver=fluentd which is correct syntax for setting Fluentd as log driver.
  3. Final Answer:

    docker run --log-driver=fluentd myimage -> Option B
  4. Quick Check:

    Correct syntax uses '=' after --log-driver [OK]
Hint: Use --log-driver=drivername with equals sign [OK]
Common Mistakes:
  • Using space instead of '=' after --log-driver
  • Using colon ':' instead of '='
  • Misspelling option name
3. Given the command:
docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 myapp

What will happen to the container logs?
medium
A. Logs will be sent to a Fluentd server running on localhost port 24224
B. Logs will be stored only inside the container
C. Logs will be sent to Docker's default json-file driver
D. Container will fail to start due to invalid log options

Solution

  1. Step 1: Analyze log driver and options

    The command sets log driver to fluentd and specifies fluentd-address as localhost:24224.
  2. Step 2: Understand effect on logs

    Logs will be forwarded to the Fluentd server at the given address instead of default storage.
  3. Final Answer:

    Logs will be sent to a Fluentd server running on localhost port 24224 -> Option A
  4. Quick Check:

    Fluentd driver + address = logs sent to Fluentd [OK]
Hint: Fluentd log driver sends logs to specified Fluentd address [OK]
Common Mistakes:
  • Assuming logs stay inside container
  • Thinking default json-file driver is used
  • Believing the command causes failure
4. You tried to run:
docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 myapp

but logs are not appearing in Fluentd. What is a likely cause?
medium
A. The container image 'myapp' does not support logging
B. The --log-driver option must be set after the image name
C. Docker does not support Fluentd as a log driver
D. Fluentd server is not running or unreachable at localhost:24224

Solution

  1. Step 1: Check Fluentd server availability

    If Fluentd server is not running or unreachable at the specified address, logs won't be received.
  2. Step 2: Verify Docker and options correctness

    Docker supports Fluentd log driver and the command syntax is correct, so these are unlikely causes.
  3. Final Answer:

    Fluentd server is not running or unreachable at localhost:24224 -> Option D
  4. Quick Check:

    Fluentd server must be running to receive logs [OK]
Hint: Check Fluentd server is running and reachable [OK]
Common Mistakes:
  • Blaming container image for logging issues
  • Thinking Docker lacks Fluentd support
  • Misplacing --log-driver option
5. You want to centralize logs from multiple Docker containers using syslog. Which is the correct way to run a container to send logs to a syslog server at 192.168.1.100 port 514?
hard
A. docker run --log-driver=syslog --log-opt syslog-address=udp://192.168.1.100:514 myapp
B. docker run --log-driver=json-file --log-opt syslog-address=tcp://192.168.1.100:514 myapp
C. docker run --log-driver=fluentd --log-opt syslog-address=udp://192.168.1.100:514 myapp
D. docker run --log-driver=syslog --log-opt syslog-address=tcp://192.168.1.100:514 myapp

Solution

  1. Step 1: Identify correct log driver for syslog

    Use --log-driver=syslog to send logs to a syslog server.
  2. Step 2: Choose correct syslog protocol and address

    Syslog commonly uses UDP protocol, so syslog-address=udp://192.168.1.100:514 is correct.
  3. Step 3: Verify options match

    docker run --log-driver=syslog --log-opt syslog-address=udp://192.168.1.100:514 myapp correctly sets syslog driver and UDP address; others use wrong driver or protocol.
  4. Final Answer:

    docker run --log-driver=syslog --log-opt syslog-address=udp://192.168.1.100:514 myapp -> Option A
  5. Quick Check:

    Syslog driver + UDP address = correct syslog logging [OK]
Hint: Syslog driver with udp:// address sends logs correctly [OK]
Common Mistakes:
  • Using TCP instead of UDP for syslog
  • Mixing Fluentd driver with syslog options
  • Using json-file driver for centralized logging
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard