By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Compose vs Kubernetes allows you to manage and orchestrate multiple containers across multiple hosts. docker-compose up
mkdir myproject && cd myproject
docker-compose.yml
version: '3' services: web: build: . ports: - "80:80"
docker-compose up
docker ps
docker-compose stop
docker-compose rm
docker-compose down
Purpose: Build a Docker image from a Dockerfile and run it.Command: docker-compose up --build Flags: --build flag tells Docker to rebuild the image if it already exists.
docker-compose up --build
--build
Purpose: Scale a service to run 3 instances.Command: docker-compose up -d --scale web=3 Flags: -d flag runs the container in detached mode, --scale flag scales the service.
docker-compose up -d --scale web=3
-d
--scale
Purpose: Link a database container to a web container.Command: docker-compose up -d --link db:database Flags: --link flag links the database container to the web container.
docker-compose up -d --link db:database
--link
Error message: Error: No such image: myimage Why it happens: The image does not exist in the local Docker registry.Fix: docker pull myimage
Error: No such image: myimage
docker pull myimage
Error message: Error: Port 80 is already in use Why it happens: Another process is using port 80.Fix: docker-compose up -p 8080
Error: Port 80 is already in use
docker-compose up -p 8080
Error message: Error: Service 'web' not found Why it happens: The service does not exist in the docker-compose.yml file.Fix: docker-compose up -f docker-compose.yml
Error: Service 'web' not found
docker-compose up -f docker-compose.yml
Situation: You want to check if a container is running.Command: docker ps Correct response: The container ID and name should be listed.
Situation: You want to check if a service is running.Command: docker-compose ps Correct response: The service name and status should be listed.
docker-compose ps
Situation: You want to check if a network is created.Command: docker network ls Correct response: The network name should be listed.
docker network ls
docker-compose logs
docker-compose exec
docker-compose config
docker-compose build
docker-compose push
docker-compose up -d
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.