-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mpoullain/docker-compose
Add a new cheat sheet for Docker Compose
- Loading branch information
Showing
16 changed files
with
266 additions
and
55 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* put your all custom css rules here */ | ||
/* you must not change other scss files */ | ||
|
||
body { | ||
// available colors are: blue, green, purple, orange and grey | ||
--currentColor: var(--blue); | ||
|
||
main div { | ||
img { | ||
height: 230px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
docker-compose version: __1.16.1__ - Date: __October 2017__ | ||
|
||
# Info | ||
|
||
Show the docker-compose version | ||
`docker-compose version` | ||
|
||
Display help and usage instructions for a command | ||
`docker-compose help` | ||
|
||
# Manage containers | ||
|
||
Build, (re)create and start containers | ||
`docker-compose up [options] [SERVICE]` | ||
|
||
* Start all containers in background: `docker-compose up -d` | ||
|
||
Stop containers and remove containers, networks, volumes, and images created. | ||
`docker-compose down [options]` | ||
|
||
Restart all stopped and running services | ||
`docker-compose restart [options] [SERVICE]` | ||
|
||
Create containers (without starting them) | ||
`docker-compose create [options] [SERVICE]` | ||
|
||
* Build images before creating containers: `docker-compose create --build` | ||
|
||
Removes stopped service containers | ||
`docker-compose rm [options] [SERVICE]` | ||
|
||
* Stop the containers, if required, before removing: `docker-compose rm --stop` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Set the number of containers to run for an existing service | ||
`docker-compose scale SERVICE=NUM` | ||
|
||
* Scale the service web with 3 containers: `docker-compose scale web=3` | ||
|
||
Start existing containers for a service | ||
`docker-compose start SERVICE` | ||
|
||
Stop running containers (without removing them) | ||
`docker-compose stop SERVICE` | ||
|
||
Pause running containers of a service | ||
`docker-compose pause SERVICE` | ||
|
||
Unpause paused containers of a service | ||
`docker-compose unpause SERVICE` | ||
|
||
Run a one-time command against a service | ||
`docker-compose run [options] SERVICE [COMMAND]` | ||
|
||
* Start the web service and runs bash as its command: `docker-compose run web bash` | ||
|
||
Force running containers to stop by sending a SIGKILL signal | ||
`docker-compose kill [options] [SERVICE]` | ||
|
||
* Kill all containers with SIGINT signal: `docker-compose kill -s SIGINT` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<html> | ||
<head> | ||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Droid+Sans:700" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
<link rel="stylesheet" href="../common.css"> | ||
<link rel="stylesheet" href="../common/lib/atom-one-light.css"> | ||
<link rel="stylesheet" href="./@@folder.css"> | ||
</head> | ||
<body> | ||
<input type="checkbox" id="showPreview"/> | ||
<div class="first-side"> | ||
@@include('../../dist/common/first-side/header.html', {"title": "Docker Compose", "subtitle": "Tool for running multi-container Docker applications", "imageName": "@@folder"}) | ||
|
||
<main> | ||
<div class="column1"> | ||
@@include('../../dist/@@folder/first-side/column1.html') | ||
</div> | ||
<div class="column2"> | ||
@@include('../../dist/@@folder/first-side/column2.html') | ||
</div> | ||
</main> | ||
|
||
@@include('../../dist/common/footer.html', {"class": "print-only"}) | ||
|
||
|
||
</div> | ||
|
||
<hr class="no-print"/> | ||
|
||
<div class="reverse"> | ||
@@include('../../dist/common/reverse/header.html', {"title": "docker-compose cheat sheet", "imageName": "@@folder"}) | ||
|
||
<main> | ||
<div class="column1"> | ||
@@include('../../dist/@@folder/reverse/column1.html') | ||
</div> | ||
<div class="column2"> | ||
@@include('../../dist/@@folder/reverse/column2.html') | ||
</div> | ||
</main> | ||
|
||
@@include('../../dist/common/footer.html') | ||
</div> | ||
|
||
<script src="../common/lib/highlight.pack.js"></script> | ||
<script src="../common/script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Manage Images | ||
|
||
Build images referenced in Compose file (without starting the containers) | ||
`docker-compose build [options] [SERVICE]` | ||
|
||
Pull images referenced in Compose file | ||
`docker-compose pull [options] [SERVICE]` | ||
|
||
Push images for services to their respective registry/repository | ||
`docker-compose push [options] [SERVICE]` | ||
|
||
# Tools | ||
|
||
Validate and view the Compose file | ||
`docker-compose config` | ||
|
||
List containers | ||
`docker-compose ps [options] [SERVICE]` | ||
|
||
Display log output from services | ||
`docker-compose logs [options] [SERVICE]` | ||
|
||
Display the running processes | ||
`docker-compose top [SERVICE]` | ||
|
||
Stream container events for every container | ||
`docker-compose events [options] [SERVICE]` | ||
|
||
List images used by the created containers | ||
`docker-compose images` | ||
|
||
Run arbitrary commands in the containers of a service | ||
`docker-compose exec [options] SERVICE COMMAND` | ||
|
||
Print the public port for a port binding | ||
`docker-compose port [options] SERVICE PRIVATE_PORT` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Compose File Example | ||
|
||
Deploying Wordpress with docker-compose : | ||
|
||
`docker-compose.yml` | ||
|
||
```yaml | ||
version: '3' | ||
|
||
services: | ||
|
||
db: | ||
image: mysql:5.7 | ||
volumes: | ||
- db_data:/var/lib/mysql | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: somewordpress | ||
MYSQL_DATABASE: wordpress | ||
MYSQL_USER: wordpress | ||
MYSQL_PASSWORD: wordpress | ||
|
||
wordpress: | ||
depends_on: | ||
- db | ||
image: wordpress:latest | ||
ports: | ||
- "8000:80" | ||
restart: always | ||
environment: | ||
WORDPRESS_DB_HOST: db:3306 | ||
WORDPRESS_DB_USER: wordpress | ||
WORDPRESS_DB_PASSWORD: wordpress | ||
|
||
volumes: | ||
db_data: | ||
``` | ||
Using : | ||
* version **3** of compose file | ||
* **2 services** (db and wordpress) | ||
* **restart policies** for containers | ||
* **ports** to access web interface | ||
* **environment variables** to initialize the database and allow wordpress to connect | ||
* **volume** to store data | ||
* **name of service** as DNS entry for **WORDPRESS_DB_HOST** | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
# Manage services | ||
|
||
Create a new service | ||
`docker service create [OPTIONS] <IMAGE> [COMMAND] [ARGS...]` | ||
`docker service create [options] IMAGE [COMMAND] [ARGS...]` | ||
|
||
* Create a busybox service: `docker service create --name busybox busybox` | ||
|
||
List all services | ||
`docker service ls` | ||
|
||
List the tasks of a service | ||
`docker service ps <SERVICE>` | ||
`docker service ps SERVICE` | ||
|
||
Remove a service | ||
`docker service rm <SERVICE>` | ||
`docker service rm SERVICE` | ||
|
||
Update a service | ||
`docker service update [OPTIONS] <service>` | ||
`docker service update [options] SERVICE` | ||
|
||
* Update service image `docker service update --image my-service:2 my-service` | ||
|
||
Scale a service | ||
`docker service scale <SERVICE>=<REPLICAS>` | ||
`docker service scale SERVICE=REPLICAS` | ||
|
||
Inspect a service | ||
`docker service inspect <SERVICE>` | ||
`docker service inspect SERVICE` | ||
|
||
Fetch the logs of a service or task | ||
`docker service logs <SERVICE>` | ||
`docker service logs <TASK>` | ||
`docker service logs SERVICE` | ||
`docker service logs TASK` | ||
|
||
Roll back a service to its previous version | ||
`docker service rollback <SERVICE>` | ||
`docker service rollback SERVICE` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.