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 an existing Docker image. docker run.
docker --version
docker pull hello-world
docker run hello-world
docker ps
docker stop <container_id>
docker rm <container_id>
docker system prune -f
Purpose: Run a container with a custom name.Command: docker run --name myhello hello-world Brief explanation of flags: --name sets the container name.
docker run --name myhello hello-world
--name
Purpose: Run a container and map port 80 to host port 8080.Command: docker run -p 8080:80 hello-world Brief explanation of flags: -p maps a host port to a container port.
docker run -p 8080:80 hello-world
-p
Purpose: Run a container with an environment variable set.Command: docker run -e MY_VAR=hello hello-world Brief explanation of flags: -e sets an environment variable.
docker run -e MY_VAR=hello hello-world
-e
Error message or symptom: docker: Error response from daemon: No such image: hello-world.Why it happens: The image was not pulled or does not exist.One-line fix: docker pull hello-world.
docker: Error response from daemon: No such image: hello-world
Error message or symptom: docker: Error response from daemon: No such container: <container_id>.Why it happens: The container was not created or does not exist.One-line fix: docker run hello-world.
docker: Error response from daemon: No such container: <container_id>
Error message or symptom: docker: Error response from daemon: Conflict: you tried to bind to port 80 which is already bound by container <container_id>.Why it happens: A container is already using the specified port.One-line fix: docker stop <container_id> and then docker rm <container_id>.
docker: Error response from daemon: Conflict: you tried to bind to port 80 which is already bound by container <container_id>
Situation: You want to check if a container is running.Command to run: docker ps What a correct response looks like: A list of running containers.
Situation: You want to check if a container is stopped.Command to run: docker ps -a What a correct response looks like: A list of all containers, including stopped ones.
docker ps -a
Situation: You want to check if an image is pulled.Command to run: docker images What a correct response looks like: A list of available images.
docker images
• docker run command flags: -d, -i, -t, -p, -e, --name • Default container name: docker-<container_id> • Default port mapping: host_port:container_port • Docker image names: docker.io/<username>/<image_name> • Docker image tags: <image_name>:<tag> • Docker container IDs: docker ps -q • Docker image IDs: docker images -q • Docker version: docker --version • Docker system prune: docker system prune -f • Docker container stop: docker stop <container_id> • Docker container remove: docker rm <container_id> • Docker image pull: docker pull <image_name> • Docker image push: docker push <image_name>
docker run
-d
-i
-t
docker-<container_id>
host_port:container_port
docker.io/<username>/<image_name>
<image_name>:<tag>
docker ps -q
docker images -q
docker pull <image_name>
docker push <image_name>
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.