freeCodeCamp/guide/english/docker/docker-compose/index.md

69 lines
1.5 KiB
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Docker compose
---
## Docker compose
Docker-Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your applications services.
The steps to use docker-compose are
```
1)create a Dockerfile which defines the image and can be producible everywhere.
2018-10-12 19:37:13 +00:00
```
```
2018-10-18 01:10:26 +00:00
2)create a docker-compose yml file to run the services
2018-10-12 19:37:13 +00:00
```
```
3)use docker-compose up to start the sevices specified in docker-compose.yml file
```
#### Basic commands in docker-compose
* Command to run docker-containers
```
docker-compose -f docker-compose.yml up
```
* Command to run containers in detached mode
```
docker-compose -f docker-compose.yml up -d
```
* command to run containers after building the images again (note: first time we run docker containers build will happen automatically)
2018-10-12 19:37:13 +00:00
```
docker-compose -f docker-compose.yml --build -d
```
* Command to stop containers when we run in detached mode
```
docker-compose -f docker-compose.yml down
```
* Command to remove service containers
```
docker-compose -f docker-compose.yml rm
```
* Command to pull Images for all service containers from repository (by default from Docker Hub)
```
docker-compose -f docker-compose.yml pull
```
* Command to view logs of all service contaienrs (add -f to follow logs)
```
docker-compose -f docker-compose.yml logs
```
2018-10-12 19:37:13 +00:00
#### More Information:
- [More information on Docker-compose](https://docs.docker.com/compose/)
2018-10-12 19:37:13 +00:00