By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Understand the difference between containers and virtual machines. docker run -it ubuntu /bin/bash
Purpose: Run a basic Ubuntu container.Command: docker run -it ubuntu /bin/bashFlags: - -it: Interactive mode, allocates a pseudo-TTY and keeps the container running.- ubuntu: The image to use.- /bin/bash: The command to run inside the container.
Purpose: Run a container from a specific image.Command: docker run -it --name my_container python:3.9 /bin/bashFlags: - -it: Interactive mode, allocates a pseudo-TTY and keeps the container running.- --name my_container: Assign a name to the container.- python:3.9: The image to use.- /bin/bash: The command to run inside the container.
Purpose: Run a container in detached mode.Command: docker run -d --name my_container python:3.9 /bin/bashFlags: - -d: Detached mode, runs the container in the background.- --name my_container: Assign a name to the container.- python:3.9: The image to use.- /bin/bash: The command to run inside the container.
Error message: 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: The Docker registry is down or your network connection is slow.One-line fix: docker pull --quiet
Error message: Error response from daemon: Container is already runningWhy it happens: The container is already running.One-line fix: docker stop && docker rm
Situation: You want to check if Docker is installed on your system.Command to run: docker --versionCorrect response: Docker version 20.10.17, build 100c701d8f
Situation: You want to check if a container is running.Command to run: docker ps -aCorrect response: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES "/bin/bash" 2 minutes ago Up 2 minutes (healthy) 80/tcp my_container
Situation: You want to check if an image is available.Command to run: docker imagesCorrect response: REPOSITORY TAG IMAGE ID CREATED SIZE 2 minutes ago 1.23GB
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.