Docker for
PHP Developers

by Sandro Keil

IT-Consultant / Senior Software Developer @prooph_software

Author, Blogger, Open Source Evangelist

https://sandro-keil.de

Agenda

  1. Docker ecosystem
  2. Benefits
  3. Hell yeah, how?
Docker

Build  Ship  Run








Virtual Machines







Docker

Docker

with

Uni
kernels

Virtual Machines Docker Containers
Docker Unikernels

Docker Image
read-only template

Docker Container
executable

Docker Toolbox

Docker Docker Docker
Images © 2016 Docker, Inc. All rights reserved.

Agenda

  1. Docker ecosystem
  2. Benefits
  3. Hell yeah, how?

Independence

No Sysadmins + no DBA's = no fight

Complete change of
development
& project
process

You Build it   You Ship it   You Run it

Agility

Are we really agile?

Or do we just like that?

Agenda

  1. Docker ecosystem
  2. Benefits
  3. Hell yeah, how?

Dockerfile

FROM prooph/php:7.0-cli

# Environmental Variables
ENV COMPOSER_HOME /root/composer
ENV COMPOSER_VERSION master

RUN apk add --no-cache --virtual .persistent-deps git unzip

RUN docker-php-ext-install zip \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Set up the application directory
VOLUME ["/app"]
WORKDIR /app

# Set up the command arguments
CMD ["-"]
ENTRYPOINT ["composer", "--ansi"]

More examples

Docker build

                $ docker build -t prooph/composer:7.0 path/to/dockerfile/
            

Docker run

                $ docker run --rm -it --volume $(pwd):/app prooph/composer:7.0 install
            

docker-compose.yml

version: '2'
services:
  nginx:
    image: prooph/nginx:www
    volumes:
      - "./public/assets:/var/www:ro"
    ports:
      - "8080:80"
      - "443:443"

  php:
    image: prooph/php:7.0-fpm
    volumes:
      - "./:/var/www"
    environment:
      - MYSQL_ROOT_PASSWORD=${APP_MYSQL_ROOT_PASSWORD}
      - MYSQL_USER=${APP_MYSQL_USER}
      - MYSQL_PASSWORD=${APP_MYSQL_PASSWORD}
      - MYSQL_DATABASE=${APP_MYSQL_DATABASE}

docker-compose.yml

  mariadb:
    image: mariadb
    volumes:
      - data-mysql:/data/db
    environment:
      - MYSQL_ROOT_PASSWORD=${APP_MYSQL_ROOT_PASSWORD}
      - MYSQL_USER=${APP_MYSQL_USER}
      - MYSQL_PASSWORD=${APP_MYSQL_PASSWORD}
      - MYSQL_DATABASE=${APP_MYSQL_DATABASE}

volumes:
  data-mysql:
    driver: local
                
                    $ docker-compose up -d --no-recreate
$ docker-compose stop
$ docker-compose down
                
example application

Production
Challenges

Orchestration   Stateful services
Know-How



Questions ?

Visit My Website