Developers need to be able to run an application on an environment as closely matched to production as possible. We can already do this through Vagrant.The problem with Vagrant is that it is slow and takes a lot of resources both in cpu and space. Docker doesn't have this problem and gives you a tool to create hundreds of different application environments on the same machine and distribute them through a registry. As Git replaced SVN, so has Docker replaced vagrant for application environment setups.Leave the future behind, own today (like a boss).
19. We Need a Dockerfile
nickbelhomme/apache nickbelhomme/foo
FROM debian:wheezy
MAINTAINER Nick Belhomme,
contact@nickbelhomme.com
RUN apt-get update
RUN apt-get install -y apache2 wget
vim curl
# expose the ports
EXPOSE 80
FROM nickbelhomme/apache
RUN a2enmod rewrite
RUN apt-get install -y php5-common
libapache2-mod-php5 php5-cli php5-
intl php5-curl php5-pgsql
ADD dev/apache/application.conf
/etc/apache2/sites-available/
application.conf
RUN a2ensite application.conf
20.
21. Actually we Need multiple Dockerfiles
1 FOR APACHE (+ PHP)
1 FOR a DB
1 PER Application
1 FOR NODE
1 FOR VARNISH
1 FOR MEMCACHED
1 FOR REDIS
1 FOR ...
Or use the Registry for pre-build images
22. Forge together
Using
Containers
docker run -d -P --name postgres nickbelhomme/postgres
docker run -d --link postgres:postgres --name applicationFoo -v
/home/nick/vhosts/foo/application:/var/www/vhosts/local.foo.com -p 49101:80
nickbelhomme/foo /usr/sbin/apachectl -D FOREGROUND
23. > docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e39 node:latest "grunt watch" 5 days ago Up 2 seconds applicationFoo-grunt
a2d applicationFoo:latest "apachectl 2 weeks ago Up 2 seconds 49101->80/tcp applicationFoo
bda postgres:latest "/usr/lib/postgresql 4 weeks ago Up 3 seconds 49155->5432/tcp
fooBar/postgres,applicationFoo/postgres,gooBar/postgres,postgres
http://local.foo.com:49101
/etc/hosts => Docker0-ip local.foo.com
32. Change the default Docker network address
> cat /etc/default/docker
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="—bip=10.66.33.10/24"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
33.
34.
35. *Mounting volumes absolute FROM GUEST
docker run -v /c/Users:containerPath
* hosts file need to be set with 192.168.59.103
36. Lightweight Tiny Core Linux made for Docker containers.
Runs completely from RAM, weighs ~27MB, boots in ~5s
37. Remember:
Keep your docker
Images single
responsibility
http://blog.nickbelhomme.com | https://joind.in/12295