WorksheetsDocker Compose Commands
Total questions: 50
Worksheet time: 8mins
Which command stops and removes containers, networks, and volumes defined in a Compose file?
podman compose stop
podman compose down
podman compose remove
podman compose clean
Which command lists running Compose services?
podman compose ls
podman compose ps
podman ps --compose
podman-compose list
What is the primary purpose of Docker Compose?
To manage single Docker containers.
To define and run multi-container Docker applications.
To orchestrate large-scale container deployments on a cluster.
To build custom Docker images from Dockerfiles.
Which file format does Docker Compose primarily use to define its services, networks, and volumes?
JSON
XML
YAML
INI
Which command is used to start all the services defined in a docker-compose.yml file?
docker start
docker compose run
docker compose up
docker compose exec
A common use case for Docker Compose in a development environment is:
Replacing a full CI/CD pipeline.
Quickly spinning up all necessary services (database, API, frontend) for a local project.
Managing hundreds of microservices in a production cluster.
Building a single, monolithic application container.
When using Compose for a multi-container application, how does Compose facilitate communication between services (e.g., a web app and a database)?
By manually configuring IP addresses for each container.
By automatically creating a default network and allowing services to resolve each other by their service names.
By requiring all services to run on the host network.
By installing a complex DNS server inside each container.
Which section in a docker-compose.yml file is used to define individual containers that make up your application?
networks
volumes
services
configs
services
What happens when you run docker compose down?
It only stops the running containers.
It removes the containers, networks, and volumes defined in the docker-compose.yml file.
It pauses all services without stopping them.
It rebuilds all the images from scratch.
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?
image:
build:
Dockerfile:
from:
Which Podman command creates a new container without starting it?
podman create
podman run
podman start
podman exec
What does the -p or --publish flag do in the podman run command?
Maps a container port to a host port
Specifies the image tag
Publishes the image to a registry
Sets environment variables
Which command starts an existing stopped container named webapp?
podman start webapp
podman run webapp
podman exec webapp
podman restart webapp
How would you expose container port 80 to host port 8080 when creating a container?
podman run -p 8080:80
podman run -p 80:8080
podman run --port 8080:80
podman run --publish 80:8080
Which command lists all containers, including those that are stopped?
podman ps -a
podman ps
podman containers --all
podman list containers
What happens when you run podman stop
Gracefully stops the running container
Removes the container
Pauses the container process
Restarts the container
To restart a running container named api-server after modifying its configuration, which command would you use?
podman restart api-server
podman reload api-server
podman reset api-server
podman exec api-server --restart
How do you view which host ports are mapped to a running container?
podman port
podman ports
podman ps --ports
podman inspect --ports
What is a Containerfile used for?
To define instructions for building a container image
To store container logs
To configure container networking
To run containers interactively
Which command builds an image from a Containerfile using Podman?
podman build -f Containerfile -t
podman run -f Containerfile
podman create --file Containerfile
podman commit Containerfile
In a Containerfile, which instruction specifies the base image?
FROM
RUN
Containers in a Docker Compose application can resolve each other by their service names.
True
False
Which Containerfile instruction executes commands during the image build process?
RUN
COPY
EXPOSE
ENTRYPOINT
How do you copy files from the build context into the image?
COPY
ADD
Both A and B
MOVE
What does the CMD instruction in a Containerfile do?
Specifies the default command to run when a container starts
Copies files into the container
Sets environment variables
Exposes network ports
Which instruction is used to define environment variables inside an image?
ENV
SET
RUN
ARG
To expose a port from the container, which Containerfile instruction is used?
EXPOSE
PORT
LISTEN
OPEN
What is the primary purpose of a volume in container environments?
To persist data beyond the container’s lifecycle
To expose container ports
To manage container networking
To scale containers
Which command creates a named volume in Podman or Docker?
podman volume create
podman volume start
podman create volume
podman volume new
How do you mount a host directory as a volume inside a container?
Using the -v /host/path:/container/path flag
Using the --network /host/path:/container/path flag
Using the --env /host/path:/container/path flag
Using the --volume-network flag
What type of volume is automatically deleted when the container is removed?
Anonymous volume
Named volume
Host volume
Persistent volume
Which command lists all volumes on a system?
podman volume ls
podman volumes
podman list volumes
podman volume show
Which of the following best describes a bind mount?
Mounting a specific directory from the host into the container
A volume managed by the container runtime
A temporary storage area within the container
A shared network file system
How can you remove an unused volume in Podman?
podman volume rm
podman volume delete
podman rm volume
podman volume clean
In Kubernetes, which object represents a volume that pods can consume?
PersistentVolumeClaim
ConfigMap
Deployment
Secret
Which command helps you identify differences between a container’s filesystem and its image?
podman diff
podman inspect
podman logs
podman status
How do you find detailed information about a container’s configuration and state?
podman inspect
podman diff
podman logs
podman status
Which command provides detailed information about a container?
podman inspect
podman status
podman config
podman describe
If a container crashes immediately after starting, which command helps you see recent output for troubleshooting?
podman logs
podman ps
podman exec -it
podman restart
To interactively debug a running container, which command is most appropriate?
podman exec -it
podman run -it
podman logs
podman stop
Which command displays resource usage (CPU, memory) of all running containers?
podman stats
podman top
podman inspect
podman usage
If container networking seems broken, which command helps verify network details?
podman network inspect
podman network ls
podman inspect
podman netinfo
What does the command podman ps -a show?
All containers, including stopped ones
Only running containers
Images on the system
Container logs
To clean up stopped containers and unused images, which command should you use?
podman system prune
podman clean all
podman rm --all
podman prune containers
How do you stop all containers started by podman-compose?
podman-compose down
podman-compose stop
podman-compose halt
podman-compose kill
Which podman-compose command rebuilds images before starting containers?
podman-compose up --build
podman-compose rebuild
podman-compose build
podman-compose restart
Which command runs a one-off command inside a podman-compose container?
podman-compose run
podman-compose exec
podman exec
podman-compose start
How do you remove all containers and networks created by podman-compose?
podman-compose down
podman-compose rm
podman-compose clean
podman-compose purge
Which command shows the logs of containers managed by podman-compose?
podman-compose logs
podman logs
podman-compose show-logs
podman-compose output
How can you run podman-compose in detached mode?
podman-compose up -d
podman-compose start -d
podman-compose run -d
podman-compose detach
