Vagrant is more similar to Fig (official orchestration tool for docker containers). Vagrant is also similar to boot2docker (Virtualbox image of Tiny Core Linux), but can use VMWare and other Linux-es Vagrant’s synced_folder are similar to boot2docker’s.
Nice illustrations and best explanation and setup: Setting up a development environment using Docker and Vagrant
cd /c/Users/Colovic/Documents ; sudo mkdir www ; cd www ; echo "<?PHP phpinfo();?>" > index.php
First time only (default mysql root password is empty):
cd /c/Users/Colovic/Documents/www docker run -d --name db -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=libidasql2 -e MYSQL_USER=libidasql2 -e MYSQL_PASSWORD="-syexye-7" -v "$(pwd)/data":/data-on-host mysql docker run -d --name app --link db:mysql -p 80:80 -v "$(pwd)":/var/www/html php:5.6-apache docker exec app a2enmod rewrite docker restart app sudo docker commit app php:5.6-apache-rewrite
Later only use:
docker start db app or
docker stop app db
To import db content:
docker exec db mysql -uroot -ppass -e "USE libidasql2; SOURCE /data-on-host/setup.sql;"
To connect inside a container (can do: multiple instances):
docker exec -it db bash
db: name: libidasql2, user: libidasql2, pass: -syexye-7
cd /c/Users/Colovic/Documents ; sudo mkdir www ; cd www ; echo “” > phpinfo.php
docker run –name=data -v /var/volume1 -v /var/volume2 rhel7-data true –volume=/c/Users/Colovic/Documents/www/data:/data-on-host
apt-get update -y && apt-get install -y php5-mcrypt
rm /etc/php5/mods-available/mcrypt.ini apt-get -y purge php5-mcrypt apt-get -y install mcrypt apt-get -y install php5-mcrypt php5enmod mcrypt
ln -s /etc/php5/mods-available/mcrypt.ini /usr/local/etc/php/conf.d/mcrypt.ini
Using Docker Compose / fig
User Docker client from Windows
You must enable Docker remote socket service, as explained earlier.
Install Docker CLI on Windows. Prebuild binaries can be downloaded from here.
wget --no-check-certificate https://master.dockerproject.com/windows/amd64/docker.exe
Now, simply use it with:
set DOCKER_HOST=tcp://192.168.0.11:2375 or command line parameter: docker --host=tcp://192.168.0.11:2375 ps
You will get an error: client and server don’t have same version (client : 1.19, server: 1.17). If you really want to manually run a new docker binary before it is updated in CoreOS, you can download the binary and run a local docker unit file. Read here
Fastest way to install boot2docker by using Vagrant: mitchellh/boot2docker-vagrant-box
Or with support for Fig? Micka33/Vagrant-docker-fig
vagrant init mitchellh/boot2docker vagrant up
boot2docker start && boot2docker ssh
Fig: Windows problem and a fix
Create an alias:
alias fig='docker run --rm -it -v $(pwd):/app -v /var/run/docker.sock:/var/run/docker.sock -e FIG_PROJECT_NAME=$(basename $(pwd)) dduportal/fig'
To make it permanent, we need to customize file
sudo touch /var/lib/boot2docker/bootlocal.sh sudo chmod +x /var/lib/boot2docker/bootlocal.sh echo 'echo "alias fig='"'"'docker run --rm -it -v \$(pwd):/app -v /var/run/docker.sock:/var/run/docker.sock -e FIG_PROJECT_NAME=\$(basename \$(pwd)) dduportal/fig'"'"'" >> /home/docker/.ashrc' | sudo tee -a /var/lib/boot2docker/bootlocal.sh sudo reboot
Important: Docker Compose is a replacement for Fig.
In boot2docker, symbolic links or junction points on Windows don’t work. You can use hard-link, but it only exist for files, not directories.
boot2docker is Tiny Core Linux. Installing an app is done with:
tce-load -wi nano.tcz
And run by:
And I want it permament in
boot2docker, so we will download a packages
to a persistent local directory. Do this only once.
cd /var/lib/boot2docker sudo mkdir tcz cd tcz for i in ncurses-common ncurses nano; do sudo wget ftp://ftp.nl.netbsd.org/vol/2/metalab/distributions/tinycorelinux/5.x/x86_64/tcz/$i.tcz; done
And make it permanent:
echo 'tce-load -i /var/lib/boot2docker/tcz/*.tcz' | sudo tee -a /var/lib/boot2docker/bootlocal.sh
OpenShift: as Proxmox, but with Docker (PaaS)
Hosted services that provide “Platform-as-a-Service” or “PaaS”.
Paas: necessary parts to quickly deploy and run a LAMP application: the web server, application server, application runtimes and libraries, database service, and so forth.
OpenShift Origin is the open source project that enables the OpenShift hosted service. Using OpenShift Origin, you can build your own PaaS.
PaaS typically runs on top of an IaaS provider. For example, both the OpenShift hosted service and the Heroku hosted service run on top of Amazon’s AWS IaaS service.
CoreOS, Project Atomic, boot2docker: stripped Linux for Docker deplyment
CoreOS uses Docker instead of a package manager. CoreOS runs on almost any platform - Vagrant, Amazon EC2, QEMU/KVM, VMware and OpenStack and your own hardware.
Project Atomic is same as CoreOS, but backed by Red Hat, and used in OpenShift.
Boot2docker is a lightweight Linux distribution based on Tiny Core Linux made specifically to run Docker containers.
Why not CoreOS? CoreOS is targeted at building infrastructure and distributed systems. Author just wanted the fastest way to boot to Docker.
OpenStack, Proxmox: IaaS
Same as Amazon AWS, but on my server.
OpenStack provides “Infrastructure-as-a-Service”, or “IaaS”. It provides bootable virtual machines, networking, block storage, object storage, and so forth.
Test solutions for free: CloudSpin
Archipel is supported in Debian, Ubuntu, ArchLinux, etc
oVirt is Red Hat based (CentOS, Fedora, etc)
SolusVM is commercial.
VirtKick is still crowdfunded
SmartOS by Joyent
Docker Hosting Services
Like Amazon AWS based on Docker. Instant Docker hosts in the cloud.
Orchard is closed, as company is aquired with Docker Inc as they are a makers of Fig.
Shell tool for Hetzner robot wertarbyte/hetzner-robot-perl
Re-install a server and put SSH key
Using Penflip as public documentation: https://www.penflip.com/
In Windows, only once:
VBoxManage sharedfolder add boot2docker-vm --name projects --hostpath c:\projects VBoxManage modifyvm boot2docker-vm --natpf1 "web,tcp,,80,,80"
sudo mkdir /projects sudo mount -t vboxsf projects /projects
And make it permanent:
echo 'sudo mkdir /projects' | sudo tee -a /var/lib/boot2docker/bootlocal.sh echo 'sudo mount -t vboxsf -o uid=1000,gid=50 projects /projects' | sudo tee -a /var/lib/boot2docker/bootlocal.sh
boot2docker/boot2docker Open Port Check Tool Deploy a PHP app with Docker, Nginx, FPM and CentOS SCL | Enalean docker-arch-php/Dockerfile at master · jprjr/docker-arch-php Deploy a PHP app with Docker, Nginx, FPM and CentOS SCL | Enalean SEED Official Blog — Creating a Docker Container to run PHP, NGINX and… Apache and PHP on Docker — Dev Tricks — Medium How to deploy PHP projects with docker dylanlindgren/docker-laravel-nginx docker-laravel-nginx/Dockerfile at master · dylanlindgren/docker-laravel-nginx docker-laravel-nginx/config at master · dylanlindgren/docker-laravel-nginx Docker for the Laravel framework enable php extension on docker php container - Google Search Best practices for writing Dockerfiles - Docker Documentation docker using dockerfile - Google Search Docker Explained: Using Dockerfiles to Automate Building of Images | DigitalOcean A Week Of Docker – Daniel Martins docker manager gui - Google Search Make Your Docker Workflow Awesome With Fig.sh mysql: Search Results | Docker Hub Registry - Repositories of Docker Images docker-library/docs Docker For WordPress Dev Environment - KatPadi’s Point
docker-wordpress-nginx-ssh/README.md at master · oskarhane/docker-wordpress-nginx-ssh What does Docker add to just plain LXC? - Stack Overflow Docker vs. Vagrant proxmox docker - Google Search hetzner-docker/README.md at master · iMelnik/hetzner-docker
A repository potentially holds multiple variants of an image. Each
variant is identified by a tag and you can refer to a tagged image like
ubuntu:14.04. If you don’t specify a variant, for example you just
ubuntu, then Docker will default to using the
The Docker Hub is a public registry maintained by Docker. Docker Registry is engine that stores and distributes images centrally and is used as a backend on Docker Hub. You can always host it by yourself.
As we can see from their prices, Docker Hub allow us unlimited public repositories, but only 1 private repositories for free.
We can search registry:
docker search mysql
Getting image from Docker Hub is easy, and doesn’t require authentication for public images.
docker pull mysql
To commit changes in container into image:
docker commit -m "First commit data image" -a "Vladan Colovic" <IMAGEHASH> cvladan/data:v00
To push that image to Docker Hub:
docker push etaktiker/data
Docker will ask you for username and password on Docker Hub. These
credentials will be securely stored in
cat ~/.dockercfg for later
To rename an image:
docker tag old/name:tag new/name:tag
Tags are just human-readable aliases so we can have more than one for
every image. You can “untag” the old name by removing the image after
you retagged it
docker rmi old/name:tag. That will just remove the
alias/tag, since image still has other names - that actual image won’t
If we have
Dockerfile we can use a
docker build command to build new
images from scratch.
Articles & sources:
Divert traffic based on hostname.
HAProxy is the best opensource loadbalancer on the market. Varnish is the best opensource static file cacher on the market. Nginx is the best opensource webserver on the market.
I will use
jwilder/nginx-proxy as it supports wildcards.
Web Control Panel with Docker
How to backup docker container volumes
If you get an error:
Repository X already being pulled by another client. Waiting.
just restart Docker service. This is in done with:
sudo systemctl restart docker
Saving a docker as image and moving it to a new host:
Docker management tools
I looked at Docker-UI and Panamax, and Docker-UI looks much simpler and cleaner for me. The possible solutions are Kubernetes (Google), Mesos, Shipyard and Docker-UI.
I found out that shipyard web GUI is not working as expected in Chrome - better use Firefox.
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock shipyard/deploy start
admin / shipyard and ad an engine
We can run
shipyard-cli with another container:
docker run -ti --rm shipyard/shipyard-cli shipyard login http://192.168.0.11:8080/ admin shipyard
Sources & articles
Docker’s image inheritance
Docker only supports running a single foreground process. Docker does not run anything by default - you have to specify exactly one foreground proces you want to run.
Best way to ensure image inheritance is by using Supervisor that itself run as a foreground process, which will keep our containers up and running.