wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Docker Compose Commands

Total questions: 50

Worksheet time: 8mins

Name
Class
Date
1.

Which command stops and removes containers, networks, and volumes defined in a Compose file?

a)

podman compose stop

b)

podman compose down

c)

podman compose remove

d)

podman compose clean

2.

Which command lists running Compose services?

a)

podman compose ls

b)

podman compose ps

c)

podman ps --compose

d)

podman-compose list

3.

What is the primary purpose of Docker Compose?

a)

To manage single Docker containers.

b)

To define and run multi-container Docker applications.

c)

To orchestrate large-scale container deployments on a cluster.

d)

To build custom Docker images from Dockerfiles.

4.

Which file format does Docker Compose primarily use to define its services, networks, and volumes?

a)

JSON

b)

XML

c)

YAML

d)

INI

5.

Which command is used to start all the services defined in a docker-compose.yml file?

a)

docker start

b)

docker compose run

c)

docker compose up

d)

docker compose exec

6.

A common use case for Docker Compose in a development environment is:

a)

Replacing a full CI/CD pipeline.

b)

Quickly spinning up all necessary services (database, API, frontend) for a local project.

c)

Managing hundreds of microservices in a production cluster.

d)

Building a single, monolithic application container.

7.

When using Compose for a multi-container application, how does Compose facilitate communication between services (e.g., a web app and a database)?

a)

By manually configuring IP addresses for each container.

b)

By automatically creating a default network and allowing services to resolve each other by their service names.

c)

By requiring all services to run on the host network.

d)

By installing a complex DNS server inside each container.

8.

Which section in a docker-compose.yml file is used to define individual containers that make up your application?

a)

networks

b)

volumes

c)

services

d)

configs

e)

services

9.

What happens when you run docker compose down?

a)

It only stops the running containers.

b)

It removes the containers, networks, and volumes defined in the docker-compose.yml file.

c)

It pauses all services without stopping them.

d)

It rebuilds all the images from scratch.

10.

In a docker-compose.yml file, if you want a service to build its image from a local Dockerfile, which instruction would you use within that service's definition?

a)

image:

b)

build:

c)

Dockerfile:

d)

from:

11.

Which Podman command creates a new container without starting it?

a)

podman create

b)

podman run

c)

podman start

d)

podman exec

12.

What does the -p or --publish flag do in the podman run command?

a)

Maps a container port to a host port

b)

Specifies the image tag

c)

Publishes the image to a registry

d)

Sets environment variables

13.

Which command starts an existing stopped container named webapp?

a)

podman start webapp

b)

podman run webapp

c)

podman exec webapp

d)

podman restart webapp

14.

How would you expose container port 80 to host port 8080 when creating a container?

a)

podman run -p 8080:80

b)

podman run -p 80:8080

c)

podman run --port 8080:80

d)

podman run --publish 80:8080

15.

Which command lists all containers, including those that are stopped?

a)

podman ps -a

b)

podman ps

c)

podman containers --all

d)

podman list containers

16.

What happens when you run podman stop ?

a)

Gracefully stops the running container

b)

Removes the container

c)

Pauses the container process

d)

Restarts the container

17.

To restart a running container named api-server after modifying its configuration, which command would you use?

a)

podman restart api-server

b)

podman reload api-server

c)

podman reset api-server

d)

podman exec api-server --restart

18.

How do you view which host ports are mapped to a running container?

a)

podman port

b)

podman ports

c)

podman ps --ports

d)

podman inspect --ports

19.

What is a Containerfile used for?

a)

To define instructions for building a container image

b)

To store container logs

c)

To configure container networking

d)

To run containers interactively

20.

Which command builds an image from a Containerfile using Podman?

a)

podman build -f Containerfile -t .

b)

podman run -f Containerfile

c)

podman create --file Containerfile

d)

podman commit Containerfile

21.

In a Containerfile, which instruction specifies the base image?

a)

FROM

b)

RUN

22.

Containers in a Docker Compose application can resolve each other by their service names.

a)

True

b)

False

23.

Which Containerfile instruction executes commands during the image build process?

a)

RUN

b)

COPY

c)

EXPOSE

d)

ENTRYPOINT

24.

How do you copy files from the build context into the image?

a)

COPY

b)

ADD

c)

Both A and B

d)

MOVE

25.

What does the CMD instruction in a Containerfile do?

a)

Specifies the default command to run when a container starts

b)

Copies files into the container

c)

Sets environment variables

d)

Exposes network ports

26.

Which instruction is used to define environment variables inside an image?

a)

ENV

b)

SET

c)

RUN

d)

ARG

27.

To expose a port from the container, which Containerfile instruction is used?

a)

EXPOSE

b)

PORT

c)

LISTEN

d)

OPEN

28.

What is the primary purpose of a volume in container environments?

a)

To persist data beyond the container’s lifecycle

b)

To expose container ports

c)

To manage container networking

d)

To scale containers

29.

Which command creates a named volume in Podman or Docker?

a)

podman volume create

b)

podman volume start

c)

podman create volume

d)

podman volume new

30.

How do you mount a host directory as a volume inside a container?

a)

Using the -v /host/path:/container/path flag

b)

Using the --network /host/path:/container/path flag

c)

Using the --env /host/path:/container/path flag

d)

Using the --volume-network flag

31.

What type of volume is automatically deleted when the container is removed?

a)

Anonymous volume

b)

Named volume

c)

Host volume

d)

Persistent volume

32.

Which command lists all volumes on a system?

a)

podman volume ls

b)

podman volumes

c)

podman list volumes

d)

podman volume show

33.

Which of the following best describes a bind mount?

a)

Mounting a specific directory from the host into the container

b)

A volume managed by the container runtime

c)

A temporary storage area within the container

d)

A shared network file system

34.

How can you remove an unused volume in Podman?

a)

podman volume rm

b)

podman volume delete

c)

podman rm volume

d)

podman volume clean

35.

In Kubernetes, which object represents a volume that pods can consume?

a)

PersistentVolumeClaim

b)

ConfigMap

c)

Deployment

d)

Secret

36.

Which command helps you identify differences between a container’s filesystem and its image?

a)

podman diff

b)

podman inspect

c)

podman logs

d)

podman status

37.

How do you find detailed information about a container’s configuration and state?

a)

podman inspect

b)

podman diff

c)

podman logs

d)

podman status

38.

Which command provides detailed information about a container?

a)

podman inspect

b)

podman status

c)

podman config

d)

podman describe

39.

If a container crashes immediately after starting, which command helps you see recent output for troubleshooting?

a)

podman logs

b)

podman ps

c)

podman exec -it /bin/bash

d)

podman restart

40.

To interactively debug a running container, which command is most appropriate?

a)

podman exec -it /bin/sh

b)

podman run -it

c)

podman logs

d)

podman stop

41.

Which command displays resource usage (CPU, memory) of all running containers?

a)

podman stats

b)

podman top

c)

podman inspect

d)

podman usage

42.

If container networking seems broken, which command helps verify network details?

a)

podman network inspect

b)

podman network ls

c)

podman inspect

d)

podman netinfo

43.

What does the command podman ps -a show?

a)

All containers, including stopped ones

b)

Only running containers

c)

Images on the system

d)

Container logs

44.

To clean up stopped containers and unused images, which command should you use?

a)

podman system prune

b)

podman clean all

c)

podman rm --all

d)

podman prune containers

45.

How do you stop all containers started by podman-compose?

a)

podman-compose down

b)

podman-compose stop

c)

podman-compose halt

d)

podman-compose kill

46.

Which podman-compose command rebuilds images before starting containers?

a)

podman-compose up --build

b)

podman-compose rebuild

c)

podman-compose build

d)

podman-compose restart

47.

Which command runs a one-off command inside a podman-compose container?

a)

podman-compose run

b)

podman-compose exec

c)

podman exec

d)

podman-compose start

48.

How do you remove all containers and networks created by podman-compose?

a)

podman-compose down

b)

podman-compose rm

c)

podman-compose clean

d)

podman-compose purge

49.

Which command shows the logs of containers managed by podman-compose?

a)

podman-compose logs

b)

podman logs

c)

podman-compose show-logs

d)

podman-compose output

50.

How can you run podman-compose in detached mode?

a)

podman-compose up -d

b)

podman-compose start -d

c)

podman-compose run -d

d)

podman-compose detach