Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

docker compose up command

docker compose up command

Docker Command ReferenceDocker Command Reference


The docker compose up command starts all service containers defined in a Docker Compose project and ensures they run according to the configuration in the docker-compose.yml file.

The docker compose up command not only starts services but also automatically builds images that have not been built yet (if necessary), creates networks and volumes, and starts services as containers.

Syntax

docker compose up [OPTIONS] [SERVICE...]

OPTIONS:

Example

1. Start all services and attach to the console



docker compose up

Starts all services defined in the Compose file and displays log output in the current terminal.

2. Run services in background mode



docker compose up -d

Runs all services in background (detached) mode; the terminal will not output service logs.

** 3. Start only specified services**



docker compose up web

Only starts the web service, not other services.

** 4. Start services and force image rebuild**



docker compose up --build

Forces service images to be rebuilt before starting services.

** 5. Start services and force container recreation**



docker compose up --force-recreate

Forces service containers to be recreated even if previous containers exist and have not changed.

6. Start services and remove orphaned containers no longer in the Compose file



docker compose up --remove-orphans

Removes any containers no longer defined in the current docker-compose.yml file.


Docker Command ReferenceDocker Command Reference