DevOps

Docker 1.6 released – Docker Machine 0.2.0

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 docker run,  --log-driver, which has three options: json-file (the default, and same as the old functionality), syslog, and none. (pull request)
  • Content Addressable Image Identifiers simplifies applying patches and updates (docs)
  • Custom cgroups using --cgroup-parent allow to define custom resources for those cgroups and put containers under a common parent group (pull request)
  • Configurable ulimit settings for all containers using --default-ulimit(pull request)
  • Apply Dockerfile instructions when committing or changing can be done using commit --change and import –change`. It allows to specify standard changes to be applied to the new image (docs)
  • Changelog

In addition, Registry 2.0, Machine 0.2, Swarm 0.2, and Compose 1.2 are also released.

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.

  1. Download Docker Machine 0.2.0:
    Aruns-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  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   401    0   401    0     0    667      0 --:--:-- --:--:-- --:--:--   668
    100 11.3M  100 11.3M    0     0  1942k      0  0:00:05  0:00:05 --:--:-- 2686k
    Aruns-iMac:~ arungupta$ chmod +x /usr/local/bin/docker-machine
  2. Verify the version:
    Aruns-iMac:~ arungupta$ docker-machine -v
    docker-machine version 0.2.0 (8b9eaf2)
  3. Download and install the latest VirtualBox.
  4. Create a Docker host using VirtualBox provider:
    Aruns-iMac:~ arungupta$ docker-machine create --driver virtualbox mydocker
    INFO[0000] Creating CA: /Users/arungupta/.docker/machine/certs/ca.pem 
    INFO[0001] Creating client certificate: /Users/arungupta/.docker/machine/certs/cert.pem 
    INFO[0003] Creating SSH key...                          
    INFO[0003] Image cache does not exist, creating it at /Users/arungupta/.docker/machine/cache... 
    INFO[0003] No default boot2docker iso found locally, downloading the latest release... 
    INFO[0003] Downloading latest boot2docker release to /Users/arungupta/.docker/machine/cache/boot2docker.iso... 
    INFO[0014] Creating VirtualBox VM...                    
    INFO[0019] Starting VirtualBox VM...                    
    INFO[0019] Waiting for VM to start...                   
    INFO[0062] "mydocker" has been created and is now the active machine. 
    INFO[0062] To point your Docker client at it, run this in your shell: eval "$(docker-machine env mydocker)"
  5. Setup client by giving the following command in terminal:
    Aruns-iMac:~ arungupta$ eval $(docker-machine env mydocker)
  6. List the Docker Machine instances running:
    Aruns-iMac:~ arungupta$ docker-machine ls
    NAME       ACTIVE   DRIVER       STATE     URL                         SWARM
    mydocker   *        virtualbox   Running   tcp://192.168.99.100:2376
  7. List Docker images and containers:
    Aruns-iMac:~ arungupta$ docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    Aruns-iMac:~ arungupta$ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    Aruns-iMac:~ arungupta$ 

    Note, there are no existing images or container.

  8. Run a trivial Java EE 7 application on WildFly using arungupta/javaee7-hol image:
    Aruns-iMac:~ arungupta$ docker run -it -p 8080:8080 arungupta/javaee7-hol
    Unable to find image 'arungupta/javaee7-hol:latest' locally
    Pulling repository arungupta/javaee7-hol
    a068decaf892: Download complete 
    511136ea3c5a: Download complete 
    5b12ef8fd570: Download complete 
    ae0c2d0bdc10: Download complete 
    e490dfcb3685: Download complete 
    f212cb9dbcf5: Download complete 
    28b11e6151f0: Download complete 
    
    . . .
    
    23:54:25,481 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017534: Registered web context: /movieplex7
    23: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/management
    23:54:25,563 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
    23: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)
  9. Find IP address of the Docker host:
    Aruns-iMac:~ arungupta$ docker-machine ip
    192.168.99.100
  10. Access the application at http://192.168.99.100:8080/movieplex7/ to see the output as:
     
    docker-machine-0.2.0-output
  11. List the images again:
    Aruns-iMac:~ arungupta$ docker images
    REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    arungupta/javaee7-hol   latest              a068decaf892        4 months ago        619.7 MB

    And the containers:

    Aruns-iMac:~ arungupta$ docker ps
    CONTAINER ID        IMAGE                          COMMAND                CREATED             STATUS              PORTS                              NAMES
    255a4d5b6f51        arungupta/javaee7-hol:latest   "/opt/jboss/wildfly/   2 seconds ago       Up 1 seconds        0.0.0.0:8080->8080/tcp, 9990/tcp   sick_elion

Enjoy!

Arun Gupta

Arun is a technology enthusiast, avid runner, author of a best-selling book, globe trotter, a community guy, Java Champion, JavaOne Rockstar, JUG Leader, Minecraft Modder, Devoxx4Kids-er, and a Red Hatter.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button