By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Run a Docker container in a CI/CD pipeline using GitHub Actions. docker run
docker --version
mkdir my-docker-project
cd my-docker-project
Dockerfile
touch Dockerfile
FROM python:3.9-slim
docker build -t my-docker-image .
docker run -it my-docker-image
docker stop <container_id>
Purpose: Expose port 80 from the container to the host machine Command: docker run -p 8080:80 my-docker-image Flags: -p maps port 8080 on the host to port 80 in the container
docker run -p 8080:80 my-docker-image
-p
Purpose: Set environment variables for the container Command: docker run -e VARIABLE=value my-docker-image Flags: -e sets an environment variable for the container
docker run -e VARIABLE=value my-docker-image
-e
Purpose: Mount a host directory as a volume in the container Command: docker run -v /host/dir:/container/dir my-docker-image Flags: -v mounts a host directory as a volume in the container
docker run -v /host/dir:/container/dir my-docker-image
-v
Error message: docker: Error response from daemon: Container <container_id> not found. Why it happens: The container was deleted or never existed.One-line fix: docker ps -a to list all containers
docker: Error response from daemon: Container <container_id> not found.
docker ps -a
Error message: docker: Error response from daemon: No such image: my-docker-image. Why it happens: The image was deleted or never existed.One-line fix: docker images to list all images
docker: Error response from daemon: No such image: my-docker-image.
docker images
Error message: docker: Error response from daemon: Volume <volume_name> not found. Why it happens: The volume was deleted or never existed.One-line fix: docker volume ls to list all volumes
docker: Error response from daemon: Volume <volume_name> not found.
docker volume ls
Situation: You want to check if a container is running Command: docker ps What a correct response looks like: A list of running containers
docker ps
Situation: You want to check if an image is available Command: docker images What a correct response looks like: A list of available images
Situation: You want to check if a volume is mounted Command: docker volume ls What a correct response looks like: A list of mounted volumes
docker run
-it
python:3.9-slim
my-docker-image
my-docker-volume
8080:80
VARIABLE=value
/host/dir:/container/dir
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.