Docker Compose Commands
- docker-compose build → When need new images. ALL IMAGES NEW
- docker-compose build mongo → just build one service. In this case, mongo
- docker-compose up -d → create & start containers as running services
(“up” does NOT rebuild images. Use “build”)
- docker-compose up --no-deps node → can add additional command lines
- docker-compose down → stops AND REMOVES all containers/services
- docker-compose down -rmi all --volumes → also removes all images & volumes
- docker-compose stop → stop services/containers. Does NOT remove
- docker-compose start → start the services/containers back up
- docker-compose logs -f → view the logs. -f = follow (outputs new logs)
- docker-compose cont-name -f → views logs of just that container
- docker-compose ps → all containers managed by docker compose
- docker-compose rm → remove ALL containers managed by docker-compose
- Differences between start & up
- $ docker-compose start
- simply starts existing containers for a service.
- $ docker-compose up
- Builds, (re)creates, starts, and attaches to containers for a service. (NOT images)
- Linked services will be started, unless they are already running.
- By default, docker-compose up will aggregate the output of each container and, when it exits, all containers will be stopped. Running docker-compose up -d, will start the containers in the background and leave them running.
- By default, if there are existing containers for a service, docker-compose up will stop and recreate them (preserving mounted volumes with volumes-from), so that changes in docker-compose.yml are picked up. If you do not want containers stopped and recreated, use docker-compose up --no-recreate. This will still start any stopped containers, if needed.
- Source: https://docs.docker.com/v1.5/compose/cli/
- $ docker-compose start