DevSecOps for BBK
  • Introduction
  • Getting Started
    • Virtual Training Practices
    • Training Plan
    • Tools and Configuration
    • Troubleshooting
  • Docker Fundamentals
    • Docker Setup
    • Docker First Container
    • Docker Network Basics
    • Docker Network Exercise
    • Docker Volume Basics
    • Docker Storage
  • Dockerfile Fundamentals
    • Dockerfile Instructions
    • Dockerfile Environment Variables
    • Dockerfile Build Arguments
    • Non-privileged Containers
    • Dockerfile Order of Execution
    • Dockerfile Volume
    • Entrypoint Command
    • Multiple Stage Build
  • Container Management
    • Containers Start Automatically
  • Docker Security
    • Seccomp Profile
  • Docker Compose
    • Docker Compose Install
    • Docker Compose Commands
    • Docker Compose File
    • Docker Compose Volumes and Network
  • K8s Cluster Setup
    • Minikube Installation
    • Calico Networking
    • K8s Walkthrough
    • K8s Cheat Sheet
  • Understand K8s
    • Pod Connectivity
    • Deployments
    • Service Cluster IP
    • Service NodePort
    • ClusterIP Exercise
    • NodePort Exercise
    • Service LoadBalancer
    • Configmap
    • Secrets
  • Application Lifecycle Management
    • Rolling Updates and Rollback
    • Multi Container Pod
  • K8s Storage
    • Persistent Volume
    • Persistent Volume Claim
    • PVC in POD
  • Istio
    • AKS Setup
    • Kubectl Setup in Windows
    • Istio Setup Manual
    • Istio Demo App
    • Istio Observability
  • Terraform
    • Terraform Setup
    • Terraform Demo
    • Azure Terraform Setup
  • Terraform AWS
    • Terraform AWS Setup
    • Terraform AWS Demo S3
  • Refrences
    • Docker Static Site
    • Docker First Image
Powered by GitBook
On this page
  • Docker Compose Commands
  • Instructions
  1. Docker Compose

Docker Compose Commands

Docker Compose Commands

In this lesson, we will start using compose by creating a compose file. Then we will create and manage the services by using the most commonly used commands:

build: Build or rebuild services

bundle: Generate a Docker bundle from the Compose file

config: Validate and view the Compose file '

create: Create services

down: Stop and remove containers, networks, images, and volumes events: Receive real time events from containers

exec: Execute a command in a running container

help: Get help on a command

images: List images

kill: Kill containers logs: View output from containers

pause: Pause services port: Print the public port for a port binding ps: List containers pull: Pull service images push: Push service images

restart: Restart services rm: Remove stopped containers run: Run a one-off command scale: Set number of containers for a service

start: Start services

stop: Stop services

top: Display the running processes

unpause: Unpause services

up: Create and start containers

version: Show the Docker-Compose version information

Instructions

Step 1: Setup your environment:

cd ~
mkdir -p compose/commands
cd compose/commands

Step 2: Create a docker-compose file:

touch docker-compose.yml

docker-compose.yml contents:

version: '3'
services:
  web:
    image: nginx
    ports:
    - "8080:80"
    volumes:
    - nginx_html:/usr/share/nginx/html/
    links:
    - redis
  redis:
    image: redis
volumes:
  nginx_html: {}

Step 4: Create a compose service:

docker-compose up -d

Step 5: List containers created by compose:

docker-compose ps

Step 6: Stopping a compose service:

docker-compose stop

Step 7: Starting a compose service:

docker-compose start

Step 8: Restarting a compose service:

docker-compose restart

Step 9: Delete a compose service:

docker-compose down
PreviousDocker Compose InstallNextDocker Compose File

Last updated 2 years ago