Create a gist now

Instantly share code, notes, and snippets.

Docker Compose v3.1 file for Secret Management under Docker 1.13
version: "3.1"
services:
db:
image: "mysql:latest"
networks:
collabnet:
aliases: ["db"]
volumes:
- "db_data:/var/lib/mysql"
secrets:
- source: "mysqlpassword"
target: "mysqlpassword"
uid: "0"
gid: "0"
mode: 0400
secrets:
- source: "mysqlrootpassword"
target: "mysqlrootpassword"
uid: "0"
gid: "0"
mode: 0400
environment:
MYSQL_ROOT_PASSWORD_FILE: "/run/secrets/mysqlrootpassword"
MYSQL_PASSWORD_FILE: "/run/secrets/mysqlpassword"
MYSQL_USER: "wordpress"
MYSQL_DATABASE: "wordpress"
deploy:
replicas: 1
placement:
constraints:
- "node.role == worker"
web:
image: "wordpress:latest"
ports:
- "80:80"
volumes:
- "wp-data:/var/www/html"
networks:
collabnet:
aliases: ["web"]
depends_on:
- db
secrets:
- source: "mysqlpassword"
target: "mysqlpassword"
uid: "0"
gid: "0"
mode: 0400
environment:
WORDPRESS_DB_USER: "wordpress"
WORDPRESS_DB_PASSWORD_FILE: "/run/secrets/wordpressdbpasswd"
WORDPRESS_DB_HOST: "mysql:3306"
WORDPRESS_DB_NAME: "wordpress"
deploy:
replicas: 1
placement:
constraints:
- "node.role == worker"
networks:
collabnet:
driver: "overlay"
internal: true
volumes:
db_data:
wp-data:
secrets:
mysqlpasswd:
external:
name: "mysqlpasswd"
secrets:
mysqlrootpaswd:
external:
name: "mysqlrootpasswd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment