0% found this document useful (0 votes)
53 views1 page

Docker Compose+YAML+Cheatsheet

This document summarizes a Docker Compose file that defines two services - a MySQL database (db) and WordPress. The db service uses the mysql:5.7 image, maps a named volume for data, and sets environment variables for the database credentials. The wordpress service declares a dependency on db, uses the wordpress:latest image, maps the host port 8000 to the container's port 80, and sets environment variables for the database connection credentials. A named volume is created and shared between the two services.

Uploaded by

StavriJosifi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

Docker Compose+YAML+Cheatsheet

This document summarizes a Docker Compose file that defines two services - a MySQL database (db) and WordPress. The db service uses the mysql:5.7 image, maps a named volume for data, and sets environment variables for the database credentials. The wordpress service declares a dependency on db, uses the wordpress:latest image, maps the host port 8000 to the container's port 80, and sets environment variables for the database connection credentials. A named volume is created and shared between the two services.

Uploaded by

StavriJosifi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Docker Compose – Decomposed

(MySQL-WordPress Example)

Compose file syntax version


(latest 3.7) version: ‘3.7’

Configuration object for


containers services:

Name of the Service db:

Base Docker image for


container created by db service image: mysql:5.7

Volume name: Mount Path volumes:


within the container
- db_data:/var/lib/mysql

restart policy set to “always” restart: always

environment:
Passing log-in info through
environment variables in
- MYSQL_ROOT_PASSWORD: abc
<key>: <value> form - MYSQL_DATABASE: wordpress
- MYSQL_USER: wordpress
- MYSQL_PASSWORD: wordpress

xfor

Name of the Second Service wordpress:

Explains service dependencies. depends_on:


wordpress service will start after db service. - db

image: wordpress:latest

Port mapping as strings between ports:


“<host_PORT>:<container_PORT>” - "8000:80“

restart: always

environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress

Create a reusable named volume for


both services. volumes:
db_data:

More Compose Parameters

You might also like