Docker Compose
|
-t, --timeout
|
specify a shutdown timeout in seconds.(default: 10)
|
docker-compose start.
|
-q, --quiet
|
Only display IDs
|
|
-f, --follow
|
Follow log output.
|
version: "3.7"
services:
wordpress_db:
container_name: "wordpress_db"
image: "mysql:5.7"
volumes:
- ~/dockers/wordpress/.data/wordpress_db:/var/lib/mysql
environment:
MYSQL_USER: gaurav
MYSQL_PASSWORD: victory
MYSQL_DATABASE: db
MYSQL_RANDOM_ROOT_PASSWORD: '1'
networks:
- wordpress_network
ports:
- 3307:3306
wordpress_web:
container_name: "wordpress_web"
image: "wordpress"
volumes:
- ~/dockers/wordpress/.data/wordpress_web:/var/www/html
environment:
WORDPRESS_DB_HOST: wordpress_db
WORDPRESS_DB_USER: gaurav
WORDPRESS_DB_PASSWORD: victory
WORDPRESS_DB_NAME: db
networks:
- wordpress_network
ports:
- 8080:80
depends_on:
- wordpress_db
networks:
wordpress_network:
db service available as the hostname databasedb is alive before starting# creates a custom network called `frontend`
networks:
frontend:
|
docker-compose up
|
use docker-compose.yml
|
|
docker-compose -f <filename.yml> -f <filenamelocal.yml> up
|
use custom yml files
|
|
-d, --detach
|
background detached mode
|
|
--build
|
forcefully Build images before starting containers.
|
|
--no-build
|
skips the image build process
|
|
--force-recreate
|
Recreate containers even if their configuration and image haven’t changed.
|
|
--no-color
|
Produce monochrome output.
|
|
--scale SERVICE=NUM
|
Scale SERVICE to NUM instances. Overrides the
scale setting in the Compose file if present. |
networks section of the Compose fileup.Networks and volumes defined as external are never removed.web:
# build from Dockerfile
build: .
# build from custom Dockerfile
build:
context: ./dir
dockerfile: Dockerfile.dev
# build from image
image: ubuntu
image: ubuntu:14.04
image: tutum/influxdb
image: example-registry:4000/postgresql
image: a4bc65fd
ports:
- "3000"
- "8000:80" # guest:host
# expose ports to linked services (not to host)
expose: ["3000"]
# command to execute
command: bundle exec thin -p 3000
command: [bundle, exec, thin, -p, 3000]
# override the entrypoint
entrypoint: /app/start.sh
entrypoint: [php, -d, vendor/bin/phpunit]
# environment vars
environment:
RACK_ENV: development
environment:
- RACK_ENV=development
# environment vars from file
env_file: .env
env_file: [.env, .development.env]
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.