Development using Docker

Table of Contents

1 Development using Docker

An introduction to using Docker in development

2 About Me

3 oppositeOf Advanced

4 Trying to Solve

  • New project setup time could be better
  • Context switching time could be better
  • Developer's environments differ from production (Nginx, linux, etc)
  • Developer's environments become a complete mess (PHP 5.6/7.0, tomcat, node, etc)
  • Setup for designers and QA was frustrating and slow

5 What is a Container

  • A stand alone web app with everything (including OS) it needs to run
  • Akin to a compiled desktop application; it "just runs"
  • Isolated from other containers
  • 👍 Easy to spin up and down
  • 👍 If hacked - scorched earth

6 Process Overview

+----------------------------------------------+
| Docker Machine (kitematic, quick start term) |
|                                              |
+----------------------------------------------+

+---------------+        +---------------+
| Dockerfile    |        | Registry      |
|               +------->|               |
|               |        |               |
+---------------+        +-------+-------+
				 |
		     +-----------v-------------------------------------+
		     |                                                 |
		     |   +---------------+         +---------------+   |
		     |   | Docker-Compose|         | Local FS      |   |
		     |   |               |         |               |   |
		     |   | app, db,      +---------+ /config       |   |
		     |   | cache, system |         | /src          |   |
		     |   |               |         |               |   |
		     |   +---------------+         +---------------+   |
		     |                                                 |
		     +----------+--------------------------------------+
				|
			+-------v--------+
			| Jenkins        |
			+-------+--------+
				|
			+-------v--------+
			| Dokku (UAT)    |
			+----------------+

7 Dockerfile

  • Used to build a 'machine' (an image)
  • Dockerfile ➡️ image
  • $ docker build -t nginx-php .
  • $ docker push the.place.com:5000/nginx-php
  • hub.docker.com

8 Dockerfile Demo

9 Docker Compose

  • Used to build a 'network'
  • docker-compose.yml
  • $ docker-compose up &
  • $ docker-compose stop

10 Docker-Compose Demo

11 File System 1

  • Basic project layout
.
├── config               -> Overrides (if needed)
│   └── nginx.conf
├── docker-compose.yml   -> Environment file
├── htdocs               -> Mounted into the VM
│   ├── index.php
│   └── test.txt
├── logs                 -> Created / Written to by the VM
│   ├── access.log
│   ├── error.log
│   ├── nginx
│   └── php5-fpm.log
└── run.command          -> Double click for Designers

12 File System 2

  • File system bridge
                  +----+                                       
+-----------+     |    |     +------------+
| VM        |     |    |     | Host       |
|  /var/www +---->|    +----->  /var/www  | 
|           |     |    |     |            |
|           <-----+    <-----+            |
|           |     |    |     |            |
+-----------+     |    |     +------------+
                  +----+

13 Useful Commands

  • docker ps ➡️ process list
  • docker exec 6e99a7a59d05 ls / ➡️ run command in container
  • docker images ➡️ list images
  • docker rmi ➡️ remove images
  • docker-compose up ➡️ startup a 'network'
  • docker-compose stop ➡️ stop a 'network'

14 Results: The Good

  • Setup time went from ~4-8 hours to ~10 Minutes
  • Take one for the team
  • Similar stack (More similar anyway)
  • Ops has a working example
  • Configuration next to code
  • Can be used to cross compile (for Go for example)

15 Results: The Whoopsie Daisy

  • File system case sensitivity
  • File system can be slow
  • When it's broke, it's confusing as
  • A lot of people hate change

16 Other things to consider

  • Windows OS based continers don't run on Linux or Mac
  • Aws Lambda / Azure Functions

17 Thanks


best viewed at 1024x768
rob.rohan@partpay.co.nz

18 You Talked too Fast Moron

  • How to remove all images (awk)
  • The 'dock' file
  • the run.command

Date: March 7, 2016

Author: @robrohan

Created: 2018-03-17 Sat 16:52

Validate