Installing the latest version of Docker on CentOS 7 minimal

I’ve been playing with docker lately and usually I want to have the latest version available as it brings bug fixes and enhancements, but I find that docker is released so quickly that the distribution releases lag behind the latest version a little bit.  Since I’ve had to repeat this process twice, I figured I’d document it and since I’m documenting it, I’d create a post.  There is nothing groundbreaking here, but it should get you up and running with the latest version of docker quickly.  The commands could be added to a simple bash script or you could create a Puppet manifest out of them.  See here for more info on installing Docker on CentOS.

Installing Docker

Download the latest version of docker:

curl -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-latest

Make the docker binary executable:

chmod +x /usr/bin/docker

We need to get some systemd files from here.

Download docker.service into the systemd directory:

curl -o /etc/systemd/system/docker.service https://raw.githubusercontent.com/docker/docker/master/contrib/init/systemd/docker.service

Download docker.socker into the systemd directory:

curl -o /etc/systemd/system/docker.socket https://raw.githubusercontent.com/docker/docker/master/contrib/init/systemd/docker.socket

Enable the docker service

systemctl enable docker.service

Start docker

systemctl start docker.service

Verify the docker version (1.6.1 at this time):

docker -v

Docker version 1.6.1, build 97cd073

Here are each of the commands:

curl -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-latest
chmod +x /usr/bin/docker
curl -o /etc/systemd/system/docker.service https://raw.githubusercontent.com/docker/docker/master/contrib/init/systemd/docker.service
curl -o /etc/systemd/system/docker.socket https://raw.githubusercontent.com/docker/docker/master/contrib/init/systemd/docker.socket
systemctl enable docker.service
systemctl start docker.service

Create a new image and container

Create a simple Dockerfile with the contents of:

FROM ubuntu:14.04
MAINTAINER Chris Greene <chris@vmware.local>
ENV REFRESHED_AT 05_12_2015
RUN apt-get -yqq update
RUN apt-get -yqq install

Build the docker image:

docker build -t chrisgreene/test .

View images:

docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
chrisgreene/test    latest              4b88ac6b0f60        2 minutes ago       209.1 MB
ubuntu                   14.04               07f8e8c5e660             12 days ago      188.3 MB

Create a container from the image:

docker run -it chrisgreene/test /bin/bash

View some info in the container:

cat /etc/os-release

NAME=”Ubuntu”
VERSION=”14.04.2 LTS, Trusty Tahr
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 14.04.2 LTS”
VERSION_ID=”14.04″
HOME_URL=”http://www.ubuntu.com/&#8221;
SUPPORT_URL=”http://help.ubuntu.com/&#8221;
BUG_REPORT_URL=”http://bugs.launchpad.net/ubuntu/&#8221;

If you’d like a book on docker but are worried about it getting out of date quickly, checkout James Turnbull’s “The Docker Book“.  When docker 1.5 came out I received an email from James on the same day announcing that version 1.5 of his book was out.  The home page still list v1.5 but on the downloads page it is v1.6.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s