Festival of Software UNISS, 21 March 2017
Labs Docker Cuba, 22 March 2017
Get them: online presentation / source code / docker image
Under Attribution 4.0 International license.
--
Based on slides for presentation in Python Meetup Thessaloniki, 15 April 2016
- Chairman of SciPyLA 2017
- Science + Python + Latin America
- Maintainer of a few Trac plugins
- Apache Bloodhound project
- Python-Cuba WG, Python Software Foundation
- Brython committer
--
- Graduated from ISPJAE (CUJAE) ... few years ago
- Fields of competence
- Antivirus
- TVC / ICRT
- Programming (web, desktop, Android, Smart TV, wearables)
- DevOps support
--
- Fields of competence (contd.)
- Fieldbus (Modbus, DNP3, radio, CANbus, Profibus)
- Big data (Apache Hadoop / Spark, Machine learning)
- Makers
- 3D printer, CNC, DRO
- DIY (Raspberry Pi, Beaglebone Black, ODROID, MicroPython, Arduino)
- History and background
- Docker overview
- Docker use cases
- Understanding Docker
- Docker examples
- Docker ecosystem
- Events coming soon
PyCon 2013 | DjangoCon 2013 |
- Solomon Hykes (@solomonstre)
- dotCloud (now Docker Inc)
- March 2013
- Apache 2.0 license
- 30k stars on Github
- 260k public repositories on hub.docker.com
- Docker Inc acquires everyone TM
- Docker joins the "Open Container Initiative", June 2015
DockerCon 2017 | PyCon 2017 |
5 tracks | 4 tutorials / 4 talks |
5,000 attendees | 3,000 attendees |
- Who knows about Docker?
- Who uses Docker for development?
- Who uses Docker in production?
- Who tried but could not do it?
Docker is an open platform for developing, shipping, and running applications.
Docker allows you to package an application with all of its dependencies into a standardized unit for software development.
--
- Fast (deployment, migration, restarts)
- Secure
- Lightweight (save disk & CPU)
- Open Source
- Portable software
- Microservices and integrations (APIs)
- Simplify DevOps
- Version control capabilities
--
- Sandbox environment (develop, test, debug, educate)
- Continuous Integration & Deployment
- Scaling apps
- Development collaboration
- Infrastructure configuration
- Local development
- Multi-tier applications
- PaaS, SaaS
See the survey results for 2016
--
--
--
--
--
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
Benjamin Hindman (Twitter) - DockerCon 2014 video
--
- Everything at Google runs in a container
- LMCTFY and Docker
- +2 billion containers per week
--
- Linux x86-64
- Go language
- Client - Server (deamon) architecture
- Union file systems (UnionFS: AUFS, btrfs, vfs etc)
- Namespaces (pid, net, ipc, mnt, uts)
- Control Groups (cgroups)
- Container format (libcontainer)
See more at Understanding docker
--
--
--
--
See more at Understanding docker
- (Docker) client
- daemon
- engine
- machine
- compose
- swarm
- registry
It is the primary user interface to Docker. It accepts commands from the user and communicates back and forth with a Docker daemon.
It runs on a host machine. The user does not directly interact with the daemon, but instead through the Docker client with the RESTful api or sockets.
A Client with a Daemon as also as the docker-compose tool. Usually referred simply as "docker".
A tool which makes it really easy to create Docker hosts on your computer, on cloud providers and inside your own data center. It creates servers, installs Docker on them, then configures the client to talk to them.
A tool for defining and running complex applications with Docker (eg a multi-container application) with a single file.
--
A native clustering tool for Docker. Swarm pools together several Docker hosts and exposes them as a single virtual Docker host. It scale up to multiple hosts.
A (hosted) service containing repositories of images which responds to the Registry API.
docker run -i -t -d ubuntu:15.04 /bin/bash
- Pulls the ubuntu:15.04 image from the registry
- 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 (
/bin/bash
) - Captures and provides application output
--
A Dockerfile is a text document that contains all the commands a user could call on the command line to create an image.
- This presentation
- Dockerfile with inline comments just for education
- Dockerfile reference on docker docs
- Official Dockerfiles (rails, nodejs, django, Drupal)
--
FROM bitnami/apache
MAINTAINER Olemis Lang <[email protected]>
# Add the whole repo.
ADD . /opt/bitnami/apache/htdocs/
# Set this as initial path when logging in via ssh.
WORKDIR /opt/bitnami/apache/htdocs/
--
// General info
man docker // man docker-run
docker help // docker help run
docker info
docker version
docker network ls
// Images
docker images // docker [IMAGE_NAME]
docker pull [IMAGE] // docker push [IMAGE]
// Containers
docker run
docker ps // docker ps -a, docker ps -l
docker stop/start/restart [CONTAINER]
docker stats [CONTAINER]
docker top [CONTAINER]
docker port [CONTAINER]
docker inspect [CONTAINER]
docker inspect -f "{{ .State.StartedAt }}" [CONTAINER]
docker rm [CONTAINER]
- SSH into a container
- Build an image
- Docker Volume
- Linked containers
- Using docker-compose
- Scale containers with docker-compose
- Share an image (share this presentation)
- Package an app with its environment
- Screen and sound within containers (x-forward)
--
docker pull ubuntu
docker run -it --name ubuntu_example ubuntu /bin/bash
--
Let's run the official jenkins image
docker pull jenkins
// Test it
docker run -d -p 8098:8080 --name jenkins_example_1 jenkins
// Open http://localhost:8098
--
Let's build a jenkins image
cd ~/Docker-presentation
git clone [email protected]:komljen/dockerfile-examples.git.git
cd dockerfile-examples/jenkins
docker build -t jenkins-local .
// Test it
docker run -d -p 8099:8080 --name jenkins_example_2 jenkins-local
// Open http://localhost:8099
--
Let's use Apache server
cd ~/Docker-presentation
mkdir apache-example
cd apache-example
docker pull bitnami/apache
docker run --name apache_volume_example \
-p 8180:80 -p 443:443 \
-v $(pwd):/opt/bitnami/apache/htdocs/ \
-d bitnami/apache
// Locally create an index.html file
echo "It works using mount." >> index.html
// Open http://localhost:8180 to view the html file
--
Bitnami offers preconfigured, zero-conf containers
docker pull bitnami/mariadb:latest bitnami/drupal:latest
docker network create drupal-tier
docker run -d --name mariadb --net drupal-tier bitnami/mariadb:latest
docker run -d -p 8081:80 -p 443:443 --name drupal --net drupal-tier bitnami/drupal:latest
--
Let's create a Drupal app (apache, php, mysql, drupal)
cd ~/Docker-presentation
mkdir drupal-link-example
cd drupal-link-example
docker pull drupal:8.0.6-apache
docker pull mysql:5.5
// Start a container for mysql
docker run --name mysql_example \
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_DATABASE=drupal \
-e MYSQL_USER=drupal \
-e MYSQL_PASSWORD=drupal \
-d mysql:5.5
// Start a Drupal container and link it with mysql
// Usage: --link [name or id]:alias
docker run -d --name drupal_example \
-p 8280:80 \
--link mysql_example:mysql \
drupal:8.0.6-apache
// Open http://localhost:8280 to continue with the installation
// On the db host use: mysql
// There is a proper linking
docker inspect -f "{{ .HostConfig.Links }}" drupal_example
--
Let's create a Drupal app with docker-compose.yml
cd ~/Docker-presentation
git clone [email protected]:cubantech/docker-presentation.git
cd docker-presentation/examples/docker-compose
// Run docker-compose using the docker-compose.yml
cat docker-compose.yml
docker-compose up -d
--
cd ~/Docker-presentation
git clone [email protected]:cubantech/docker-presentation.git
cd docker-presentation
docker pull bitnami/apache
docker build -t olemis/docker-presentation .
// Test it
docker run -itd --name docker_presentation \
-p 8480:80 \
olemis/docker-presentation
// Open http://localhost:8480, you should see this presentation
// Push it on the hub.docker.com
docker push olemis/docker-presentation
--
docker pull nimmis/alpine-apache
docker run -d --name apache_example \
nimmis/alpine-apache
// Create a file inside the container.
// See http://github.com/nimmis/docker-alpine-apache for details.
docker exec -ti apache_example \
/bin/sh -c 'mkdir /test && echo "This is it." >> /test/test.txt'
// Test it. You should see message: "This is it."
docker exec apache_example cat /test/test.txt
// Commit the change.
docker commit apache_export_example myapache:latest
// Create a new container with the new image.
docker run -d --name myapache_example myapache
// You should see the new folder/file inside the myapache_example container.
docker exec myapache_example cat /test/test.txt
// Export the container as image
cd ~/Docker-presentation
docker export myapache_example > myapache_example.tar
// Import a new image from the exported files
cd ~/Docker-presentation
docker import myapache_example.tar myapache:new
// Save a new image as tar
docker save -o ~/Docker-presentation/myapache_image.tar myapache:new
// Load an image from tar file
docker load < myapache_image.tar
--
See examples at hub.docker.com/u/jess
// Before staring we should grant access to everyone on the X Server (locally)
// Otherwise the containers below will never start and they will not be able to use x11
xhost +
// Libreoffice
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name libreoffice \
jess/libreoffice
// SublimeText 3
docker run -it \
-v $HOME/.config/sublime-text-3/:/root/.config/sublime-text-3 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--name sublime_text \
jess/sublime-text-3
// Audacity (sound in docker container)
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-e QT_DEVICE_PIXEL_RATIO \
--device /dev/snd \
--group-add audio \
--name audacity \
jess/audacity
// Disable access to x11
xhost -
There are known best practices (see a list at examples/tips)
- Optimize containers (check fromlatest.io and imagelayers.io)
- Create your own tiny base
- Containers are not Virtual Machines
- Full stack Images VS 1 process per Container
- Create your private registry
- Create shortcut commands
- Use docker-compose.yml templates (see why at lorry.io)
- Be aware of the hub.docker.com docker agent version
Type | Software |
---|---|
Clustering/orchestration | Swarm, Kubernetes, Marathon, MaestroNG, decking, shipyard, Apache Mesos |
Docker registries | Portus, Docker Distribution, hub.docker.com, quay.io, Google container registry, Artifactory, projectatomic.io |
PaaS with Docker | Rancher, Tsuru, dokku, flynn, Octohost, DEIS |
OS made of Containers | RancherOS |
--
See the survey results for 2016
- Rocket, rkt
- Linux Containers, LXC
- Linux container hypervisor, LXD
- BSD Jails
- Solaris Zones
- drawbridge
- Awesome Docker (list of Docker resources & projects)
- Docker cheat sheet
- Docker in Practice, The Docker Book, Using Docker
- Docker aliases/shortcuts
- Docker case studies
Join us - forms.cuban.tech/volunteer/es
- Docker Cuba meetups docker.cuban.tech
- Docker birthday #4 celebration in all provinces
- Emergent Computing Technologies Workshop
- Infrastructure for Reproducible Research
- ... with Docker ! \o/
--
- Submission deadline 30th September 2017
- Apply as referee
- Instructions for authors
--
- Submit your talks / workshops bit.ly/scipyla2017-actividades-tech
- Submit posters
Next: Docker in production, Scaling, Private registries, PaaS.