Fatskills
Practice. Master. Repeat.
Study Guide: Docker Docker Introduction to Docker Docker vs Podman vs containerd
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-introduction-to-docker-docker-vs-podman-vs-containerd

Docker Docker Introduction to Docker Docker vs Podman vs containerd

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~4 min read

1. Core Command / Concept

Run a container from a Docker image. docker run

2. Step-by-Step

  1. Install Docker on your system: sudo apt-get update && sudo apt-get install docker.io
  2. Check if Docker is running: sudo systemctl status docker
  3. Pull a Docker image: docker pull ubuntu
  4. Run a container from the image: docker run -it ubuntu /bin/bash
  5. ⚠️ List all running containers: docker ps
  6. Stop a container: docker stop <container_id>
  7. ⚠️ Delete all stopped containers: docker system prune -f
  8. Clean up: docker rm <container_id>

3. Real Commands with Examples


Example 1: Run a container with a specific port

Purpose: Expose port 80 from the container.
Command: docker run -p 8080:80 -it ubuntu /bin/bash Flags: -p maps host port 8080 to container port 80, -it allows interactive shell.

Example 2: Run a container with a volume

Purpose: Mount a host directory to the container.
Command: docker run -v /host/dir:/container/dir -it ubuntu /bin/bash Flags: -v mounts a volume from the host to the container, -it allows interactive shell.

Example 3: Run a container with environment variables

Purpose: Set environment variables in the container.
Command: docker run -e VARIABLE=value -it ubuntu /bin/bash Flags: -e sets an environment variable in the container, -it allows interactive shell.

4. Common Errors


Error 1: "docker: Got permission denied while trying to connect to the Docker daemon socket."

Why it happens: Insufficient permissions to access the Docker socket.
Fix: sudo docker <command>

Error 2: "docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on [::1]:53: dial unix /run/systemd/resolve/resolv.conf: connect: no such file or directory."

Why it happens: DNS resolution issue.
Fix: sudo systemctl restart systemd-resolved

Error 3: "docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)."

Why it happens: Connection timeout.
Fix: docker pull <image> --quiet

5. Quick Checks


Scenario 1: Check if a container is running

Situation: You want to check if a container is running.
Command: docker ps Correct response: A list of running containers.

Scenario 2: Check the Docker version

Situation: You want to check the Docker version.
Command: docker --version Correct response: The Docker version number.

Scenario 3: Check the container logs

Situation: You want to check the container logs.
Command: docker logs <container_id> Correct response: The container logs.

6. Last-Minute Reference

• Docker daemon socket: /var/run/docker.sock • Docker registry: https://registry-1.docker.io • Docker image format: Dockerfile • Docker container format: json • Docker volume format: json • Docker network format: json • Docker container ID length: 12 characters • Docker image ID length: 12 characters • Docker volume mount point: /mnt • Docker network interface: eth0 • Docker container restart policy: no • Docker container remove force flag: -f • Docker container prune force flag: -f • Docker system prune force flag: -f • Docker version command: docker --version • Docker info command: docker info • Docker system info command: docker system info • Docker container stats command: docker stats • Docker container top command: docker top • Docker container logs command: docker logs • Docker container exec command: docker exec • Docker container attach command: docker attach • Docker container start command: docker start • Docker container stop command: docker stop • Docker container kill command: docker kill • Docker container rm command: docker rm • Docker container prune command: docker system prune • Docker image pull command: docker pull • Docker image push command: docker push • Docker image tag command: docker tag • Docker image rm command: docker rmi • Docker image prune command: docker image prune • Docker network create command: docker network create • Docker network inspect command: docker network inspect • Docker network connect command: docker network connect • Docker network disconnect command: docker network disconnect • Docker network rm command: docker network rm • Docker network prune command: docker network prune • Docker volume create command: docker volume create • Docker volume inspect command: docker volume inspect • Docker volume rm command: docker volume rm • Docker volume prune command: docker volume prune • Docker system df command: docker system df • Docker system info command: docker system info • Docker system prune command: docker system prune • Docker system stats command: docker system stats • Docker system events command: docker system events • Docker system logs command: docker system logs • Docker system inspect command: docker system inspect




ADVERTISEMENT