Introduction to Docker
Course outline
-
What is Docker?
-
Setting up your Docker environment
-
Docker basics
-
Docker in practice
-
Further learning
Virtualization tool?
Configuration manager?
VM manager?
cgroups?
LXC?
libvirt?
go?
Docker.com says
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.
Docker Engine
A portable, lightweight runtime and packaging tool
Docker Hub
A cloud service for sharing applications and automating workflows
Less portable, minimal overhead
Most portable,
lots of overhead
Manual
configuration
Traditional VMs
CM tools
Docker
This is what makes Docker so powerful
Containers
Applications run in containers
$ docker run busybox /bin/echo "hello world"
hello world
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Images
Saved states of containers.
$ docker history atbaker/sd-django
IMAGE CREATED CREATED BY SIZE
2c69173d3c3e 6 months ago /bin/sh -c apt-get clean && rm -rf /var/lib/a 7 B
cf07ee82aaa6 6 months ago /bin/sh -c chown root /opt/sd_client.py /var/ 1.162 kB
4a3046bdcd25 6 months ago /bin/sh -c #(nop) ADD file:0854b61af5a8f7051c 259 B
519ac326d2de 6 months ago /bin/sh -c #(nop) ADD file:03065d55ff7e64caa9 896 B
5f87ccb7c84f 6 months ago /bin/sh -c chown root /etc/service/gunicorn/r 871 B
aa069b102781 6 months ago /bin/sh -c #(nop) ADD file:4683e735d1f7a57fd5 864 B
da64e86860ea 6 months ago /bin/sh -c mkdir /etc/service/gunicorn 7 B
9109839d1887 6 months ago /bin/sh -c touch /var/log/gunicorn/error.log 7 B
5e628a947f45 6 months ago /bin/sh -c touch /var/log/gunicorn/access.log 7 B
57b25445ef0b 6 months ago /bin/sh -c mkdir /var/log/gunicorn 7 B
dc008bbf46e8 6 months ago /bin/sh -c /var/www/venv/bin/django-admin.py 747.5 kB
d75444a0b891 6 months ago /bin/sh -c /var/www/venv/bin/django-admin.py 45.49 kB
4b6f8f5021aa 6 months ago /bin/sh -c #(nop) ENV SECRET_KEY=no-so-secret 0 B
93a3749a8817 6 months ago /bin/sh -c #(nop) ENV DJANGO_SETTINGS_MODULE= 0 B
3d67fca00fe8 6 months ago /bin/sh -c #(nop) ENV PYTHONPATH=$PYTHONPATH: 0 B
1b2851b048f7 6 months ago /bin/sh -c /var/www/venv/bin/pip install -r / 30.19 MB
7c9a3b2daefb 6 months ago /bin/sh -c virtualenv /var/www/venv 11.62 MB
6b468cc8cefe 6 months ago /bin/sh -c pip install virtualenv 1.921 MB
Dockerfiles (builder)
Series of commands to build an image
# Spin-docker example dockerfile for a Django project
# Use phusion/baseimage as base image
FROM phusion/baseimage:0.9.8
MAINTAINER Andrew T. Baker <andrew@andrewtorkbaker.com>
# Add the Django app and install its requirements
ADD sd_sample_project /var/www/django
RUN apt-get install -y python-pip
RUN pip install virtualenv
RUN virtualenv /var/www/venv
RUN /.../venv/bin/pip install -r /.../requirements.txt
...
Docker Engine
Manages containers on your machine
Docker Hub
Common registry of Docker images
Docker
Repository
Git
Repository
collection of commits
Container
Checkout
used for local execution
Docker Hub
GitHub
popular remote server
Image
Commit
saved state
Andrew T. Baker
Introduction to Docker (from O'Reilly video)
By Andrew T. Baker
Introduction to Docker (from O'Reilly video)
Deck used in my O'Reilly Introduction to Docker video tutorial
- 2,395