Introduction to Docker Compose

Fri Jun 10, 2016

Docker CEO here.

Introduction

Docker Compose (originally Fig) is written in Python.

Docker-Compose provides a template for running one or more containers

Most of the command line options for ”docker run” can be specified in the docker-compose.yml file Simplifies and documents what is required to run the docker containers

Docker-compose allows to have a single document for all environments via injection of Environment variables

Developers can start/stop/rebuild containers without any deep knowledge of Docker

Configuration is in one YAML file: ‘docker-compose.yml’ YAML is the cleanest data format

Docker-Compose has traditionally been focused on development and testing workflows on a single host.

Using Compose is basically a three-step process

  • Define your app’s environment with a “Dockerfile” so it can be reproduced anywhere
  • Define the services that make up your app in “docker-compose.yml” so they can be run together in an isolated environment
  • Run “docker-compose up” and Docker Compose will start and run your entire app

Installation

Docker for Mac and Docker for Windows includes both Engine and Compose, so Mac and Windows users do not need to install Docker Compose separately.

For Linux users, follow the directions here: https://docs.docker.com/compose/install/

Upgrade containers

Reference: http://staxmanade.com/2016/09/how-to-update-a-single-running-docker-compose-container/ To bring up all the service containers with a simple docker-compose up starts everything. However, what if you want to replace an existing container without tearing down the entire suite of containers? do it with a single command

 docker-compose up -d --no-deps --build <service_name>

https://realpython.com/blog/python/dockerizing-flask-with-compose-and-machine-from-localhost-to-the-cloud/

NEXT: perhaps add to my powerpoint deck?

NOTE: libcompose also referenced in ael.txt

docker-compose (originally Fig) is Python, rancher-compose uses libcompose in Go, which rancher contributed to Docker. lib-compose is currently maintained by Docker and added Compose V2 support in July. Lib-compose is used by rancher-compose, openshift, amazon-ecs-cli, compose2kube and other projects. https://forums.rancher.com/t/why-not-support-a-docker-compose-file-with-a-configured-mysql-image-to-run-rancher-server/1783/5 https://github.com/docker/libcompose

MISC http://developers.redhat.com/blog/2016/03/09/more-about-docker-images-size/

Docker environment variable file

Finally implemented 11/13/2016  for docker-aws
Env file for AWS secret key
(Until u can setup hashi vault)

done with 'env_file' https://docs.docker.com/compose/compose-file/#env-file

decided against updating used goodies with awscli.  probably not needed - just run separate containers?
jliu@JEFFREYs-MacBook-Pro ~ $ docker network inspect $(docker network ls -q) | | jq -r '.[].Name , .[].IPAM.Config'

or

for i in $(docker network ls -q); do docker network inspect $i | jq -r '.[].Name, .[].IPAM.Config'; done


https://docs.docker.com/compose/compose-file/

version: '2'

services:
  app:
    image: busybox
    command: ifconfig
    networks:
      app_net:
        ipv4_address: 172.18.18.10

networks:
  app_net:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 172.18.18.0/24
        gateway: 172.18.18.1