Bird
Raised Fist0
Dockerdevops~5 mins

Docker engine and runtime - Commands & Configuration

Choose your learning style10 modes available
Introduction
Docker Engine is the software that runs containers on your computer. It lets you package apps and their settings so they work the same everywhere. The runtime part means it actually runs these containers safely and efficiently.
When you want to run multiple apps on the same computer without them interfering with each other
When you need to test your app in an environment identical to production
When you want to share your app with others so they can run it easily
When you want to isolate your app from the host system for security
When you want to quickly start and stop apps without installing them
Commands
This command shows the installed Docker Engine version and runtime details to confirm Docker is installed and running.
Terminal
docker version
Expected OutputExpected
Client: Docker Engine - Community Version: 24.0.2 API version: 1.42 Go version: go1.20.5 Git commit: 123abc4 Built: Thu May 2 12:00:00 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.2 API version: 1.42 (minimum version 1.12) Go version: go1.20.5 Git commit: 123abc4 Built: Thu May 2 12:00:00 2024 OS/Arch: linux/amd64 Experimental: false
This command gives detailed information about the Docker Engine and runtime environment, including number of containers, images, and storage driver.
Terminal
docker info
Expected OutputExpected
Client: Context: default Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 2 Server Version: 24.0.2 Storage Driver: overlay2 Backing Filesystem: extfs Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Kernel Version: 5.15.0-70-generic Operating System: Ubuntu 22.04.2 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.7GiB Name: example-host ID: ABCD:1234:EFGH:5678:IJKL:9012:MNOP:3456:QRST:7890:UVWX:YZ12 Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/
This command runs a small test container to verify the Docker Engine and runtime can start containers correctly. The --rm flag removes the container after it exits.
Terminal
docker run --rm hello-world
Expected OutputExpected
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pull complete Digest: sha256:abc123def4567890abcdef1234567890abcdef1234567890abcdef1234567890 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
→
--rm - Automatically remove the container when it exits
This command lists all containers, including stopped ones, to check the state of containers managed by Docker Engine and runtime.
Terminal
docker ps -a
Expected OutputExpected
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
→
-a - Show all containers, not just running ones
Key Concept

If you remember nothing else from this pattern, remember: Docker Engine is the core software that runs containers, and the runtime is what actually starts and manages those containers safely.

Common Mistakes
Trying to run containers without Docker Engine installed or running
Docker commands fail because the engine is not available to create or manage containers
Install Docker Engine and ensure the Docker service is running before running containers
Not using --rm flag when running short test containers
Containers remain stopped and clutter the system, using disk space and making management harder
Use --rm flag to automatically clean up containers after they exit
Confusing docker version output with docker info output
docker version shows version numbers only, docker info shows detailed runtime environment; mixing them can cause misunderstanding
Use docker version to check versions, docker info to check environment and runtime details
Summary
Use 'docker version' to check Docker Engine and runtime versions.
Use 'docker info' to see detailed runtime environment and system info.
Run 'docker run --rm hello-world' to test if Docker Engine can start containers.
Use 'docker ps -a' to list all containers and their states.

Practice

(1/5)
1. What is the primary role of the Docker engine in container management?
easy
A. It manages and controls containers on your system.
B. It builds the Linux kernel for container support.
C. It acts as a cloud service for container hosting.
D. It provides a graphical interface for container design.

Solution

  1. Step 1: Understand Docker engine's function

    The Docker engine is the main software that manages containers, including building, running, and controlling them.
  2. Step 2: Compare options with this role

    Only It manages and controls containers on your system. correctly states that Docker engine manages and controls containers on your system.
  3. Final Answer:

    It manages and controls containers on your system. -> Option A
  4. Quick Check:

    Docker engine = container management [OK]
Hint: Docker engine controls containers, not builds kernels or UI [OK]
Common Mistakes:
  • Confusing Docker engine with cloud services
  • Thinking Docker engine builds the OS kernel
  • Assuming Docker engine is a GUI tool
2. Which of the following is the correct command to check the Docker engine version?
easy
A. docker version
B. docker check-version
C. docker show version
D. docker engine info

Solution

  1. Step 1: Recall Docker command syntax for version

    The correct command to check Docker engine version is docker version.
  2. Step 2: Validate other options

    Options A, B, and C are not valid Docker commands for checking version.
  3. Final Answer:

    docker version -> Option A
  4. Quick Check:

    Check version command = docker version [OK]
Hint: Use 'docker version' to see engine version quickly [OK]
Common Mistakes:
  • Using incorrect command names like 'docker check-version'
  • Confusing 'docker info' with version command
  • Trying 'docker engine info' which is invalid
3. What will be the output of the command docker ps when no containers are running?
medium
A. Displays an error saying no containers found
B. Lists all containers including stopped ones
C. Shows an empty list with only headers
D. Starts a new container automatically

Solution

  1. Step 1: Understand what 'docker ps' shows

    The command docker ps lists running containers only, showing headers even if none are running.
  2. Step 2: Analyze output when no containers run

    When no containers run, it shows an empty list with column headers but no container entries.
  3. Final Answer:

    Shows an empty list with only headers -> Option C
  4. Quick Check:

    docker ps with no containers = empty list [OK]
Hint: 'docker ps' shows running containers; empty if none run [OK]
Common Mistakes:
  • Thinking it lists stopped containers too
  • Expecting an error message when no containers run
  • Assuming it starts containers automatically
4. You run docker run -d nginx but get an error: "Cannot connect to the Docker daemon." What is the likely cause?
medium
A. The container is already running.
B. The nginx image does not exist on Docker Hub.
C. The command syntax is incorrect.
D. Docker daemon is not running on the system.

Solution

  1. Step 1: Understand the error message

    "Cannot connect to the Docker daemon" means the Docker engine service (daemon) is not running or accessible.
  2. Step 2: Check other options

    Image absence or syntax errors cause different errors; container running does not cause daemon connection errors.
  3. Final Answer:

    Docker daemon is not running on the system. -> Option D
  4. Quick Check:

    Daemon connection error = daemon not running [OK]
Hint: Daemon errors mean Docker service is stopped or unreachable [OK]
Common Mistakes:
  • Assuming image absence causes daemon errors
  • Blaming command syntax for daemon connection issues
  • Thinking container running causes this error
5. You want to run a container using a runtime other than the default Docker runtime. Which command option lets you specify the runtime?
hard
A. docker run --use-runtime=<runtime_name> <image>
B. docker run --runtime=<runtime_name> <image>
C. docker run --engine=<runtime_name> <image>
D. docker run --container-runtime=<runtime_name> <image>

Solution

  1. Step 1: Recall Docker run options for runtime

    The correct option to specify a runtime is --runtime followed by the runtime name.
  2. Step 2: Verify other options

    Options A, B, and D are not valid Docker CLI options for runtime selection.
  3. Final Answer:

    docker run --runtime=<runtime_name> <image> -> Option B
  4. Quick Check:

    Specify runtime with --runtime option [OK]
Hint: Use '--runtime' option to select container runtime [OK]
Common Mistakes:
  • Using incorrect flags like --engine or --use-runtime
  • Confusing runtime with engine options
  • Omitting the runtime option entirely
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