Skip to content

davidkroell/docker-deepdive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker deep-dive

Presentation about Docker. Every snippet can be executed in a free Play with Docker instance.

In this presentation, the following topics are covered:

  • Difference to VMs
  • Image vs. Container
  • Registry
  • Dockerfile
  • docker-compose
  • Storage
  • Networking
  • Swarm
  • Monitoring

Images

Exploring Images with Docker Toolset

df
# Output:
# Filesystem     1K-blocks     Used Available Use% Mounted on
# overlay        318111924 76532844 225400856  26% /var/lib/docker/overlay2/5570076c75...345/merged

# change into mount path
cd /var/lib/docker/overlay2/5570076c75...345/merged

ls
# notice, that this is an os and boot directory is empty or missing

Exploring Docker Images with Dive

docker pull wagoodman/dive # download image
docker inspect wagoodman/dive # show info

docker pull bitnami/laravel:5 # get Larvel image

# exmplore image with dive
docker run --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wagoodman/dive:latest bitnami/laravel:5

Containers

Run a container

# mongodb
docker run mongo

# advanced mysql deployment
docker run --name mysql57 –d \
	--restart=always \
	–p 127.0.0.1:3306:3306 \
	-v mysql:/var/run/mysql \
	-e MYSQL_ROOT_PASSWORD=my-secret-pw \
	mysql:5.7

Use Dockers JSON API

curl --unix /var/run/docker.sock http:80/containers/json

Access Docker daemon from windows. Requires local docker client executable in path with at least Docker 18.09 on client and server.

docker -H ssh://user@host ps
# or for advanced use
set DOCKER_HOST=ssh://user@host
# for powershell:
# $Env:DOCKER_HOST += "ssh://user@host"
docker ps

Build Docker Image

Build a Docker Image

git clone https://github.com/ironarachne/namegen # get code

cd namegen # change in code dir
git checkout 2a28fd8 # check out working code

# build image
docker build -t me/namegen .

# use image
docker run me/namegen

# with parameters
docker run me/namegen -o korean -n 10 -m firstname

Networking and Storage

Docker networks and volumes

docker network ls

docker volume ls

docker-compose

Docker Compose

# install compose
# not needed in PWD
curl -sSL https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` \
  -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# check out this repo
git clone https://github.com/davidkroell/docker-deepdive
cd docker-deepdive

# deploy wordpress service
docker-compose -f wordpress-compose.yml up

Docker Swarm

Start the Docker Swarm Visualizer

docker service create \
  --name=viz \
  --publish=8080:8080/tcp \
  --constraint=node.role==manager \
  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
  dockersamples/visualizer

Deploy Hello world in Docker Swarm

docker service create \
  --name=hello \
  -p 8000:80 \
  tutum/hello-world

Check availability of Hello world

while true; do
curl -s <URL> | grep "My hostname"
sleep 0.2;
done

Scale Hello world service

docker service scale hello=3

Update the service

# set update policy
docker service update -d --update-order start-first hello

docker service update \
  --image jwilder/whoami \
  --publish-rm 80 \
  --publish-add 8000:8000 hello

Deploy the same Wordpress as earlier using Docker Swarm

docker stack deploy --compose-file wordpress-compose.yml wordpress

Monitoring

Basic container monitoring

docker container stats

Deploy prometheus monitoring stack

# deploy dev stack
git clone https://github.com/stefanprodan/swarmprom.git
cd swarmprom

ADMIN_USER=admin \
ADMIN_PASSWORD=admin \
SLACK_URL=https://hooks.slack.com/services/TOKEN \
SLACK_CHANNEL=devops-alerts \
SLACK_USER=alertmanager \
docker stack deploy -c docker-compose.yml mon

About

Presentation about the Docker ecosystem

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published