Docker 1.6 was released yesterday. The key highlights are:
- Container and Image Labels allow to attach user-defined metadata to containers and images (blog post)
- Docker Windows Client (blog post)
- Logging Drivers allow you to send container logs to other systems such as Syslog or a third-party. This available as a new option to
--log-driver, which has three options:
json-file(the default, and same as the old functionality),
none. (pull request)
- Content Addressable Image Identifiers simplifies applying patches and updates (docs)
- Custom cgroups using
--cgroup-parentallow to define custom resources for those cgroups and put containers under a common parent group (pull request)
- Configurable ulimit settings for all containers using
- Apply Dockerfile instructions when committing or changing can be done using
import –change`. It allows to specify standard changes to be applied to the new image (docs)
This blog will show how to get started with Docker Machine 0.2.0. Subsequent blogs will show how to use Docker Swarm 0.2.0 and Compose 1.2.
Download Docker Client
Docker Machine takes you from zero-to-Docker on a host with a single command. This host could be your laptop, in the cloud, or in your data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them.
It works with different drivers such as Amazon, VMWare, and Rackspace. The easiest to start on a local laptop is to use VirtualBox driver. More details on configuring Docker Machine in the next section. But in order for Docker commands to work without having to use SSH into the VirtualBox image, we need to install Docker CLI.
Lets do that!
Aruns-iMac:~ arungupta$ curl https://get.docker.com/builds/Darwin/x86_64/docker-latest > /usr/local/bin/docker
chmod +x /usr/local/bin/docker
If you have installed Boot2Docker separately, then there is Docker CLI included in the VM. But this approach would allow you to directly call multiple hosts from your local machine.
Docker Machine 0.2.0
Learn more details about Docker Machine and how to getting started with version 0.1.0. Docker 1.6 released Docker Machine 0.2.0. This section will talk about how to use that and configure it on Mac OS X.
- Download Docker Machine 0.2.0:
12345678Aruns-iMac:~ arungupta$ curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 401 0 401 0 0 667 0 --:--:-- --:--:-- --:--:-- 668100 11.3M 100 11.3M 0 0 1942k 0 0:00:05 0:00:05 --:--:-- 2686kAruns-iMac:~ arungupta$ chmod +x /usr/local/bin/docker-machine
- Verify the version:
1234Aruns-iMac:~ arungupta$ docker-machine -vdocker-machine version 0.2.0 (8b9eaf2)
- Download and install the latest VirtualBox.
- Create a Docker host using VirtualBox provider:
1234567891011121314Aruns-iMac:~ arungupta$ docker-machine create --driver virtualbox mydockerINFO Creating CA: /Users/arungupta/.docker/machine/certs/ca.pemINFO Creating client certificate: /Users/arungupta/.docker/machine/certs/cert.pemINFO Creating SSH key...INFO Image cache does not exist, creating it at /Users/arungupta/.docker/machine/cache...INFO No default boot2docker iso found locally, downloading the latest release...INFO Downloading latest boot2docker release to /Users/arungupta/.docker/machine/cache/boot2docker.iso...INFO Creating VirtualBox VM...INFO Starting VirtualBox VM...INFO Waiting for VM to start...INFO "mydocker" has been created and is now the active machine.INFO To point your Docker client at it, run this in your shell: eval "$(docker-machine env mydocker)"
- Setup client by giving the following command in terminal:
123Aruns-iMac:~ arungupta$ eval $(docker-machine env mydocker)
- List the Docker Machine instances running:
12345Aruns-iMac:~ arungupta$ docker-machine lsNAME ACTIVE DRIVER STATE URL SWARMmydocker * virtualbox Running tcp://192.168.99.100:2376
- List Docker images and containers:
1234567Aruns-iMac:~ arungupta$ docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEAruns-iMac:~ arungupta$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESAruns-iMac:~ arungupta$
- Run a trivial Java EE 7 application on WildFly using arungupta/javaee7-hol image:
1234567891011121314151617181920Aruns-iMac:~ arungupta$ docker run -it -p 8080:8080 arungupta/javaee7-holUnable to find image 'arungupta/javaee7-hol:latest' locallyPulling repository arungupta/javaee7-hola068decaf892: Download complete511136ea3c5a: Download complete5b12ef8fd570: Download completeae0c2d0bdc10: Download completee490dfcb3685: Download completef212cb9dbcf5: Download complete28b11e6151f0: Download complete. . .23:54:25,481 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017534: Registered web context: /movieplex723:54:25,513 INFO [org.jboss.as.server] (ServerService Thread Pool -- 31) JBAS018559: Deployed "movieplex7-1.0-SNAPSHOT.war" (runtime-name : "movieplex7-1.0-SNAPSHOT.war")23:54:25,563 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management23:54:25,563 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:999023:54:25,564 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 8093ms - Started 400 of 452 services (104 services are lazy, passive or on-demand)
- Find IP address of the Docker host:
1234Aruns-iMac:~ arungupta$ docker-machine ip192.168.99.100
- Access the application at http://192.168.99.100:8080/movieplex7/ to see the output as:
- List the images again:
12345Aruns-iMac:~ arungupta$ docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEarungupta/javaee7-hol latest a068decaf892 4 months ago 619.7 MB
12345Aruns-iMac:~ arungupta$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES255a4d5b6f51 arungupta/javaee7-hol:latest "/opt/jboss/wildfly/ 2 seconds ago Up 1 seconds 0.0.0.0:8080->8080/tcp, 9990/tcp sick_elion