This document provides an overview of Docker for developers. It discusses why Docker is useful for building applications, including portability across machines, isolating dependencies, and creating development environments that match production. Benefits of Docker like lightweight containers, a unified build process with Dockerfiles, standardized images from Docker Hub, and fast container startup times are outlined. Some cons like only working on Linux and added complexity are noted. Using Docker with Vagrant for a portable development environment is presented. Key Docker CLI commands and Docker Compose for defining multi-container apps are covered. Tips for debugging running containers are provided.
2. Justyna Ilczuk,
Senior Software / DevOps Engineer
at
Speaker
A scalable backend that helps developers
build complex apps
with only front-end code.
http://www.syncano.com/
3.
4. Docker - An open platform for distributed
applications for developers and sysadmins.
* Powered by Linux Containers.
Build, Ship and Run
Any App, Anywhere
7. Why?
Isolate and version dependencies on both
language and OS level
- better than virtualenv (rvm)
8. Why?
Build Dev Environment than resembles
production environment
- avoid strange bugs from dev/prod mismatch
9.
10. Why?
Installing dockerized services is trivial
- You need a Postgres in version 9.4? Or
redis, or Rabbitmq, Elastic Search?
Just pull an image and start a container.
17. Docker pros
Fast, starting container in 0.2 s
$ time docker run --rm ubuntu /bin/echo hello world
hello world
docker run --rm ubuntu /bin/echo hello world 0,02s user 0,01s system 9% cpu
0,271 total
18. Docker pros - summing up
● lightweight containers
● unified build process (Dockerfile)
● standardized images (Docker hub)
● fast, starting container in 0.2 s
● combining containers together
● distributed apps, microservices
19. Docker cons
● works only on GNU/Linux (needs vagrant /
boot2docker)
● new tool to learn
● another layer of complexity & overhead -
vagrant + Docker vs developing natively on
your machine
21. Docker + Vagrant
● Works everywhere
● Possible to try new tech, new OSes
○ CoreOS
○ Kubernetes
○ Mesos
○ etcd
○ Consul
● Distributed apps on your laptop
39. Compose - good for running
containers
But missing dependencies.
40. Updating images
● Developers Bob and Alice work on an App.
● They use docker-compose to run App
● Bob adds new feature that requires Dependency X to be
baked into Docker image
● He updates the requirements.txt file that is used in
Dockerfile and rebuilds his image
41. Updating images
● Cool feature is merged to trunk
● Alice pulls changes
● Alice starts docker-compose and app breaks, because
of missing dependency in the container
42. Technical of people problem?
Should Alice remember to run `docker-
compose build`, `docker-compose rm` and
`docker-compose up` after each pull?
48. Ups… something went wrong.
Building image failed.
- it stops at layer that failed
- starts from the last correct layer (cache)
49. Ups… something went wrong.
App in containers behaves in a strange way:
Logs and errors
- logging to stdout
- logging to volumes
- logging straight to Centralized Logging
- logging to sentry
51. Ups… something went wrong.
Operating on a live patient -
Debugging running containers
- no need for ssh
- … no need for nsenter
- $ docker exec -it my_container bash