Skip to content

Instantly share code, notes, and snippets.

@FrankV01
Created October 21, 2023 01:18
Show Gist options
  • Select an option

  • Save FrankV01/32806b0069f267ee94b9c85459b73489 to your computer and use it in GitHub Desktop.

Select an option

Save FrankV01/32806b0069f267ee94b9c85459b73489 to your computer and use it in GitHub Desktop.
Docker Compose Reference

I intend to convert this to Markdown.

# --------------------------------------------------------------------------
# docker compose up -d  #Create & Start the stack and detach
# docker compose up --force-recreate --build -d #Create & Start the stack and detach
# docker compose down   #Stop and **Destroy** the stack (Does NOT remove the volume)
# docker compose down -v #Stop and **Destroy** the stack and **REMOVE** the volume
#
# docker compose stop  #Stop the stack. Does not destroy it.
# docker compose start  # [re]start the stack.
#
# docker exec -it <container_name> /bin/bash # Get a **bash shell** in the **container**.
#
# docker compose ps [-a]    #List the stack; [-a] = inc. stopped containers
# docker compose top   #List the processes running in the stack
#
# docker compose logs   #List the logs for both/all containers
# docker compose logs -f    #List the logs for both/all containers and follow
# docker compose logs -f ghost   #List the logs for the ghost container and follow
#
# docker volume ls   #List the volumes (note: not a docker compose cmd)
#
# docker compose pause  #Pause the stack
# docker compose unpause #Unpause the stack
# --------------------------------------------------------------------------
#
# The following is for docker swarm mode; an alternative to compose but
#  more complex
# --------------------------------------------------------------------------
# docker stack deploy -c ghost-mysql-stack.yml ghost
# Usage:  docker stack deploy [OPTIONS] STACK
#
# Swarm initialized: current node (yl0yu4g75a1te93m0ba7vdhd2) is now a manager.
# To add a worker to this swarm, run the following command:
#     docker swarm join --token SWMTKN-1-1bxnrsni0ju6niojwupf93bunhijay8nmymmlyqrfr4c3s3axz-0yu99xcuszwv35gl3hl80ef5f 192.168.65.4:2377
# To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
#
# Try this: docker-compose -f ghost-mysql-stack.yml up
# --------------------------------------------------------------------------
# docker swarm init  <-- Told us we needed a swarm so we created this.
#  Later leared that ^ swarm isn't the only option. `docker-compose` is another option.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment