liveBook · Manning

Docker compose up

As explained in Road to Kubernetes

docker compose up -d is a Docker Compose command that creates and starts Compose application services in detached mode.

docker compose up creates and starts the services declared in a Compose file. Run it from the application directory; use docker compose up -d to keep services running in detached mode. section 6.2.2 section 7.3.3

Use related commands to control the Compose application:

  • Run docker compose up to start the application in the foreground, or docker compose up -d to start it detached. section 6.2.2 section 7.3.3
  • Run docker compose up --build after changing a service Dockerfile so the service image is rebuilt before startup. section 6.4.2
  • Run docker compose down to stop services and clean up Compose-managed resources; use docker compose down -v when attempting to remove volumes. section 6.2.2 section 6.3.2
  • Use docker compose exec service command to inspect files or run commands inside a running service without identifying its container ID. section 6.3.2

Start a Python web service

With a compose.yaml defining a web service that builds from Dockerfile, maps port 8080, and sets PORT=8080, run docker compose up. Open another terminal to run docker compose down. section 6.2.2

Start production services remotely

After copying compose.yaml and .env to a virtual machine and pulling updated images, change to the application directory and run docker compose up -d. Compose starts the production web service using its image and environment file. section 7.3.3

Listing 6.3 Docker Compose for our Python app
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    environment:
      - PORT=8080

Shows the minimal Compose configuration needed to build and start the Python web service. section 6.2.2

How Road to Kubernetes covers it

How deep it goes
Demonstrates foreground, detached, rebuilt, volume, and multi-service startup, but does not detail Compose configuration options comprehensively.
Examples
Uses Python and Node.js web services, mounted data volumes, and a Redis service in local and production Compose configurations.
What it assumes
Assumes a Docker project and Compose configuration while demonstrating basic service, port, environment, volume, and image settings.
What you can do after
Operate/configure Compose applications, rebuild changed services, inspect running containers, and deploy detached services remotely.
How it connects
Connects Docker Compose with containers, Dockerfiles, volumes, Redis, dotenv files, Docker Hub, SSH, and GitHub Actions.

Also explained in

Compare how 2 books explain docker compose up →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.