Docker-Machine

Some basics to start with docker machine.

docker-machine ls #list all remote daemons
docker-machine active #show active daemon
#change to different VM
docker-machine env default
#connect your shell to the new machine
eval $("docker-machine.exe" env default)

#run the first container
docker run ubuntu echo hello world
docker run -d -p 8000:80 httpd:2.4
curl $(docker-machine ip default):8000
docker ps #get container id
docker stop #stop container
docker stop $(docker ps -a) #stop all container
docker-machine create -d virtualbox --virtualbox-cpu-count 2 --virtualbox-memory 6144 --virtualbox-disk-size 15000 devdays #create a docker daemon in virtualbox

Docker

  • License: Apache 2.0
  • Started by Solomon Hykes at dotCloud
    • Jeff Lindsay independent collaborator
  • Released as open source in March 2013
  • In the years 2013 – 2016 many organizations started to support Docker
    • Cisco, Google, Huawei, IBM, Microsoft, and Red Hat
  • October 2015, the project had over 25,600 GitHub stars

Source: https://de.wikipedia.org/wiki/Docker_(Software)
Picture Source:
https://commons.wikimedia.org/wiki/File:Docker_(container_engine)_logo.svg

LXC → libcontainer

  • Operating System Level Virtualization (no Hypervisor)
    • based on Linux Containers (LXC)
    • March 2014, with release version 0.9 Docker dropped LXC
  • Development of “libcontainer” started
    • cross-system abstraction layer
    • Docker execution environment
    • builds up a new container specification
    • wraps control-groups, namespaces and UnionFS
  • Similar implementations
    • rkt, FreeBSD Jail, OpenVZ, system-nspawn

Picture License: Public Domain
https://commons.wikimedia.org/wiki/File:Docker-linux-interfaces.svg#/media/File:Docker-linux-interfaces.svg

OS manages everything

  • a container is an isolation by defining limits through kernel features
    • Namespaces
      • process ids, hostnames, user ids and network access isolation
    • cgroups
      • Resource Management/-Limiting, CPU, memory, disk I/O, network
  • Docker introduces copy-on-write storage to manage images and containers
  • Docker aims to simplify and abstract this kernel level operations
  • a container feels like a VM but exists only due to an isolation mechanism provided by the OS

Docker as an abstraction layer

  • Software
    • Docker daemon
      • listens to requests sent via Docker-Engine-API (REST)
    • Docker client
      • uses Docker-Engine-API
  • Objects
    • Images
    • Containers
    • Services
  • Registries
    • Hub
    • Sharing Images
    • Public: Docker Hub, Docker Cloud
  • Platform independent Container Specification

Docker Images and Containers

  • Images
    • built up from a series of layers
    • each represents an instruction in a dockerfile or may be a manual configuration
    • layers are read only, except the last one
  • Container
    • a read write layer
    • to be able to modify data which was read in an image layer, a copy-on-write process must be performed
    • copy-on-write copies a file from an image layer to the container layer before the system can modify it
    • all modifications may only be done on container layer
  • Flexible and Fast
    • it is possible to start multiple containers of the same kind quickly
    • versioning is easy to implement

Docker Volumes

  • Volumes
    • define a volume which will be available in a container as folder
    • managed by Docker daemon on host
    • enables a sharing mechanism between containers
    • flexible, as directly managed by Docker and thus platform independent
    • remotely available
    • may be started pre-populated in a container, to avoid copy-on-write
  • Bind Mounts
    • directly mount a host folder into a container
    • not managed by Docker, not platform independent
  • Tmpfs mounts
    • temporary and only in memory
    • useful for sensitive data
    • no sharing, only on linux

Registry and Services

  • Registries enable sharing of images
    • push images to a registry to start sharing
    • pull images, to start from
    • thousands of apps available, each in an single image
    • different application versions, pre-configured in images
  • Public Registries
    • Docker Hub, Docker Cloud
  • Services
    • Scale containers across Docker daemons, swarm

Used to interact with Docker daemon

  • Docker-Toolbox
    • works on Windows and Mac
    • needs a virtualization driver to load a boot2docker iso
      • Virtualbox
      • Hyper-V
    • provides Docker-machine command to remotely interact with the Docker host, which is running in a VM
  • DockerCLI
    • provides commands to interact with the daemon, interacts mostly over Docker-Engine-API
  • Docker-Compose
    • runs multi-container Docker applications
    • configure a landscape using a YAML file
    • define ports, networks, volumes, environment variables, start order, dependencies
  • Kubernetes
    • Container Orchestration
    • automated deployment, scaling, and management

Sources:

https://docs.docker.com/engine/docker-overview/
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
https://docs.docker.com/storage/storagedriver/#images-and-layers
https://docs.docker.com/compose/overview/
https://docs.docker.com/machine/
https://en.wikipedia.org/wiki/Docker_(software)
http://jancorg.github.io/blog/2015/01/03/libcontainer-overview/
https://github.com/docker/libcontainer/blob/4940cee052ece5a8b2ea477699e7bb232de1e1f8/SPEC.md
https://www.infoq.com/news/2013/03/Docker
https://github.com/torvalds/linux

  • start.txt
  • Last modified: 2019/01/04 16:03
  • by alexejsailer