docker-compose: update

This commit is contained in:
Rico Sta. Cruz 2017-09-20 22:00:15 +08:00
parent 5052978005
commit 7d907dc836
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 59 additions and 22 deletions

View File

@ -1,8 +1,14 @@
---
title: docker-compose
category: Devops
layout: 2017/sheet
prism_languages: [yaml]
weight: -1
updated: 2017-09-20
---
### Basic example
```yaml
# docker-compose.yml
version: '2'
@ -18,22 +24,26 @@ services:
image: redis
```
## Command
### Commands
```sh
docker-compose start
docker-compose stop
```
```sh
docker-compose pause
docker-compose unpause
```
```sh
docker-compose ps
docker-compose up
docker-compose down
```
## Reference
{: .-one-column}
```yaml
web:
@ -92,26 +102,53 @@ web:
- ./_data:/var/lib/mysql
```
## Less-often used
## Advanced features
{: .-three-column}
### Labels
```yaml
web:
labels:
com.example.description: "Accounting web app"
# change dns servers
dns: 8.8.8.8
dns:
- 8.8.8.8
- 8.8.4.4
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
external_links:
- redis_1
- project_db_1:mysql
extra_hosts:
- "somehost:192.168.1.100"
services:
web:
labels:
com.example.description: "Accounting web app"
```
### DNS servers
```yaml
services:
web:
dns: 8.8.8.8
dns:
- 8.8.8.8
- 8.8.4.4
```
### Devices
```yaml
services:
web:
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
```
### External links
```yaml
services:
web:
external_links:
- redis_1
- project_db_1:mysql
```
### Hosts
```yaml
services:
web:
extra_hosts:
- "somehost:192.168.1.100"
```