0
0
Dockerdevops~20 mins

Sidecar container pattern in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sidecar Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Sidecar Containers

What is the main purpose of using a sidecar container in a Docker pod or deployment?

ATo add auxiliary features like logging or monitoring alongside the main application container
BTo replace the main application container with a backup container
CTo run multiple unrelated applications in the same container
DTo increase the CPU resources available to the main container by sharing cores
Attempts:
2 left
💡 Hint

Think about how sidecar containers help the main app without changing its code.

💻 Command Output
intermediate
2:00remaining
Output of Docker Compose with Sidecar

Given this docker-compose.yml snippet, what will be the output when running docker-compose up?

Docker
version: '3.8'
services:
  app:
    image: busybox
    command: sh -c "echo Main app running; sleep 5"
  sidecar:
    image: busybox
    command: sh -c "echo Sidecar running; sleep 5"
A
Main app running
Sidecar running
BMain app running
CSidecar running
DError: service 'sidecar' not found
Attempts:
2 left
💡 Hint

Both services run their commands concurrently when using docker-compose up.

Configuration
advanced
2:30remaining
Correct Sidecar Volume Sharing Configuration

Which Docker Compose configuration correctly shares a log directory between the main app and sidecar containers?

A
services:
  app:
    volumes:
      - ./logs:/var/log/app
  sidecar:
    volumes:
      - ./logs:/var/log/app
B
services:
  app:
    volumes:
      - logs:/var/log/app
  sidecar:
    volumes:
      - logs:/var/log/app
volumes:
  logs:
C
services:
  app:
    volumes:
      - logs:/var/log/app
  sidecar:
    volumes:
      - ./logs:/var/log/app
volumes:
  logs:
D
services:
  app:
    volumes:
      - ./logs:/var/log/app
  sidecar:
    volumes:
      - logs:/var/log/app
volumes:
  logs:
Attempts:
2 left
💡 Hint

Look for a named volume shared by both containers.

Troubleshoot
advanced
2:00remaining
Sidecar Container Fails to Start

You have a sidecar container configured to collect logs, but it fails to start with the error: OCI runtime exec failed. What is the most likely cause?

AThe sidecar container has no network access
BThe main container is not running
CThe sidecar container's command is invalid or missing
DThe Docker daemon is stopped
Attempts:
2 left
💡 Hint

Check the command or entrypoint of the sidecar container.

🔀 Workflow
expert
3:00remaining
Sidecar Container Logging Workflow

In a Kubernetes pod using the sidecar pattern for logging, which sequence correctly describes the workflow for log collection?

A1,3,2,4
B2,1,3,4
C3,1,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint

Think about the natural flow of logs from creation to storage.