Intro to Docker

For Wordpress Development

Who am I ?

Joshua Burke

Teacher and Mentor

Meetup Organizer

Ruby Developer

Part-time DevOps

Not a Wordpress Dev

( ^ this is encouraging )

What is Docker ?

Docker allows you to package an application with all of its dependencies into a standardized unit for software development.

How is it different ?

Docker is not a virtual machine manager

Why is it better ?

Start time                                         ( seconds v.s. minutes )

Server resources                            ( 128MB v.s. 1GB RAM )

Consistency                               ( no more "works for me" )

Idempotent  builds                ( same instructions always )

Isolation of dependencies      ( Redis/MySQL in Docker )

Easy to share containers      ( docker pull image_name )

Docker Architecture

The big picture

Docker Architecture

   OSX              ||         Linux           ||         Windows

Docker Friends

Engine || Machine || Compose || Registry || Swarm

Docker Engine

Primary runtime

# run an some_container and shut it down after exit

$ docker run -it some_container some_command

# list all the containers available within local docker host

$ docker ps -a 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
ee51d10253ae        ubuntu              "bash"              30 minutes ago      Exited (0) 17 seconds ago                       jolly_jones
1f7f1f55c9e2        hello-world         "/hello"            32 minutes ago      Exited (0) 32 minutes ago                       gloomy_kirch

Docker Files

Container Dependencies

FROM ubuntu:latest
RUN apt-get update
RUN apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
    mysql-client mysql-server apache2 libapache2-mod-php5     
    pwgen python-setuptools vim-tiny php5-mysql  php5-ldap
RUN easy_install supervisor
ADD ./scripts/start.sh /start.sh
ADD ./scripts/foreground.sh /etc/apache2/foreground.sh
ADD ./configs/supervisord.conf /etc/supervisord.conf
ADD ./configs/000-default.conf /etc/apache2/sites-available/000-default.conf
RUN rm -rf /var/www/
ADD https://wordpress.org/latest.tar.gz /wordpress.tar.gz
RUN tar xvzf /wordpress.tar.gz 
RUN mv /wordpress /var/www/
RUN chown -R www-data:www-data /var/www/
RUN chmod 755 /start.sh
RUN chmod 755 /etc/apache2/foreground.sh
RUN mkdir /var/log/supervisor/
EXPOSE 80
CMD ["/bin/bash", "/start.sh"]

Docker Machine

Creates and manages the VM running Docker

$ docker-machine start default

> Starting VM...

$ eval "$(docker-machine env default)"

$ env | ack DOCK
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_CERT_PATH=/Users/mansfield/.docker/machine/machines/default
DOCKER_MACHINE_NAME=default

Docker Compose

Configures ports, env, and links between containers

# project_dir/docker-compose.yml
---
web:
  build: .
  ports:
   - "5000:5000"
  volumes:
   - .:/code
  links:
   - redis
redis:
  image: redis

docker-compose.yml

# from within same dir as docker-compose.yml

$ docker-compose up

Pulling image redis...
Building web...
Starting composetest_redis_1...
Starting composetest_web_1...
redis_1 | [8] 02 Jan 18:43:35.576
web_1   |  * Running on http://0.0.0.0:5000/
web_1   |  * Restarting with stat

Docker-compose CLI

Docker Registry (Hub)

Store private or use open source containers 

Docker Swarm

Setup and manage a cluster of hosts

Kitematic

Live Demo ... maybe

Made with Slides.com