By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Run a container from a Docker image. docker run
sudo apt-get update && sudo apt-get install docker.io
sudo systemctl status docker
docker pull ubuntu
docker run -it ubuntu /bin/bash
docker ps
docker stop <container_id>
docker system prune -f
docker rm <container_id>
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.
docker run -p 8080:80 -it ubuntu /bin/bash
-p
-it
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.
docker run -v /host/dir:/container/dir -it ubuntu /bin/bash
-v
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.
docker run -e VARIABLE=value -it ubuntu /bin/bash
-e
Why it happens: Insufficient permissions to access the Docker socket.Fix: sudo docker <command>
sudo docker <command>
Why it happens: DNS resolution issue.Fix: sudo systemctl restart systemd-resolved
sudo systemctl restart systemd-resolved
Why it happens: Connection timeout.Fix: docker pull <image> --quiet
docker pull <image> --quiet
Situation: You want to check if a container is running.Command: docker ps Correct response: A list of running containers.
Situation: You want to check the Docker version.Command: docker --version Correct response: The Docker version number.
docker --version
Situation: You want to check the container logs.Command: docker logs <container_id> Correct response: The container logs.
docker logs <container_id>
• 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
/var/run/docker.sock
https://registry-1.docker.io
Dockerfile
json
/mnt
eth0
no
-f
docker info
docker system info
docker stats
docker top
docker logs
docker exec
docker attach
docker start
docker stop
docker kill
docker rm
docker system prune
docker pull
docker push
docker tag
docker rmi
docker image prune
docker network create
docker network inspect
docker network connect
docker network disconnect
docker network rm
docker network prune
docker volume create
docker volume inspect
docker volume rm
docker volume prune
docker system df
docker system stats
docker system events
docker system logs
docker system inspect
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.