Containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server.
This guarantees that it will always run the same, regardless of the environment it is running in.
Are read-only templates
Composed by layers using Union File System
Parent image + new layers
User added files
Metadata
UnionFS + namespaces + cgroups
Image + new read-write layer
Pulls the ubuntu image from docker hub
Creates a new container
Allocates a filesystem and mounts a read-write layer
Allocates a network / bridge interface
Sets up an IP address
Executes a process that you specify
Captures and provides application output
docker run -i -t ubuntu /bin/bash
FROM
ENV
ADD
COPY
WORKDIR
RUN
EXPOSE
VOLUME
USER
CMD
ONBUILD
example
nginx
django
redis
postgres
data
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
volumes:
- /usr/src/app/static
env_file: .env
command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
postgres:
restart: always
image: postgres:latest
volumes_from:
- data
ports:
- "5432:5432"
redis:
restart: always
image: redis:latest
ports:
- "6379:6379"
data:
restart: always
image: postgres:latest
volumes:
- /var/lib/postgresql
docker-machine create -d virtualbox dev;
eval "$(docker-machine env dev)"
docker-machine ls
New docker machine
docker-compose build
docker-compose up -d
docker-compose run web /usr/local/bin/python manage.py migrate
git clone git@git.sophilabs.io:ssassi/test-docker-django.git
Clone repo, build it and run it!
docker ps -a
a GUI for lazies
Cluster Managers
Official clustering solution for docker, including scheduling, scalability and availability management
Strategies for containers allocation on available hosts
Available filters for containers allocation on available hosts
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://08c73c596622ad6010d22ad4ec043ca7 swarm-master
Let's create a cluster
master
slave nodes
docker-machine create -d virtualbox --swarm --swarm-discovery token://08c73c596622ad6010d22ad4ec043ca7 swarm-agent-00
docker-machine create -d virtualbox --swarm --swarm-discovery token://08c73c596622ad6010d22ad4ec043ca7 swarm-agent-01
eval $(docker-machine env --swarm swarm-master)
...adding a new container
get info
slave nodes
docker run hello-world
docker info
docker ps -a
Docker containers
Dockerfile
Docker hub
Kitematic
Docker compose
Docker machine
Docker swarm