Provisioning environments with Docker

David Flores

Co-Mantainer at @DrupalConsole, Linux, Drupal, Symfony, Silex, BackEnd, Seguridad, Python, Open Source, Father ...sometimes #Nerd Speaker

david@indava.com

@dmouse

Open Source

http://drupalconsole.com

Open Source

https://github.com/dmouse

Community

https://phpmexico.mx

Provisioners

Abstracción

API ó Servicio

Provisioners

  • Ansible
  • Puppet
  • Chef
  • Terraform
  • Salt

Myself with Docker 0.6.5

Cuando todo era felicidad

Docker Compose

Yaml

Sobreescribir valores

Override

# docker-compose.yml

web:
  image: apache:latest
  ports:
    - 80:80
  links:
    - db
    - cache

db:
  image: postgres:latest

cache:
  image: redis:latest
# docker-compose.override.yml

web:
  environment:
    ENV: 'dev'
  ports:
    - 8883:80

$ docker-compose -f docker-compose.yml up -d

Override

# docker-compose.yml

web:
  image: apache:latest
  ports:
    - 80:80
  links:
    - db
    - cache

db:
  image: postgres:latest

cache:
  image: redis:latest
# docker-compose.prod.yml

web:
  environment:
    ENV: 'prod'

$ docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

Tasks

# docker-compose.yml

web:
  image: apache:latest
  ports:
    - 80:80
  links:
    - db
    - cache

db:
  image: mysql:5.7

cache:
  image: redis:latest
# docker-compose.backup.yml

backup:
  image: mysql:5.7
  volumes:
     - ./backups:/data
  links:
     - db

$ docker-compose -f docker-compose.yml -f docker-compose.backup.yml run backup backup.sh

Docker Machine

Docker Wrapper

docker-machine

 ~  ./docker-machine                                                                                                                                                                        
Create and manage machines running Docker.
  
Commands:
  active		Print which machine is active
  config		Print the connection config for machine
  create		Create a machine
  env			Display the commands to set up the environment for the Docker client
  inspect		Inspect information about a machine
  ip			Get the IP address of a machine
  kill			Kill a machine
  ls			List machines
  provision		Re-provision existing machines
  regenerate-certs	Regenerate TLS Certificates for a machine
  restart		Restart a machine
  rm			Remove a machine
  ssh			Log into or run a command on a machine with SSH.
  scp			Copy files between machines
  start			Start a machine
  status		Get the status of a machine
  stop			Stop a machine
  upgrade		Upgrade a machine to the latest version of Docker
  url			Get the URL of a machine
  version		Show the Docker Machine version or a machine docker version
  help			Shows a list of commands or help for one command
  
Run 'docker-machine COMMAND --help' for more information on a command.

docker-machine create

$ docker-machine create \
--driver digitalocean \
--digitalocean-access-token $DOTOKEN \
--digitalocean-image ubuntu-16-04-x64 \
machine-name

docker-machine ls

NAME               ACTIVE      DRIVER         STATE     URL                         SWARM   DOCKER    ERRORS
ubuntu1604-docker    -        digitalocean   Running   tcp://104.236.120.71:2376            v1.11.1

Within Docker



eval $(docker-machine env machine-name)

Docker



docker run -d -p 8080:80 --name httpserver nginx

Tareas por hacer

  • Crear docker-compose.yml
  • Pensar en variables de entorno
  • Crear scripts para acortar el uso docker-compose
  • Usar más imagenes contribuidas y personalizarlas
  • Contribuir a esas imagenes

David Flores

Co-Mantainer at @DrupalConsole, Linux, Drupal, Symfony, Silex, BackEnd, Seguridad, Python, Open Source, Father ...sometimes #Nerd Speaker

david@indava.com

@dmouse

https://slides.com/dmouse/provisioners

provisioners

By David Flores

provisioners

  • 1,387