Skip to content

Using Docker on CERN CentOS 7

About Docker

"Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment." - docker.com/what-docker

Installation and configuration

CERN CentOS 7 provides two versions of docker:
  • docker - stable version 1.10 with backported patches.
  • docker-latest - latest version updated periodically - 1.13 (Apr 2017).
To install run on your system as root:
# yum install docker
# yum install docker-latest
Note: While two above versions can be installed in parallel, only one can be used on the system at any given time (different data storage paths, different system services started).

To configure and start docker system service run:

# systemctl enable docker
# systemctl start docker
and run docker using:
# /usr/bin/docker -v
Docker version 1.10.3, build cb079f6

To configure and start docker-latest system service run:

# systemctl enable docker-latest
# systemctl start docker-latest
and in addition edit /etc/sysconfig/docker adding a line:
DOCKERBINARY=/usr/bin/docker-latest
and run docker using:
# /usr/bin/docker -v
Docker version 1.12.1, build 84527a0

Documentation

CERN base images

We provide (and regularily update) prebuilt Docker images for: Scientific Linux CERN 5, Scientific Linux CERN 6 and CERN CentOS 7.

Please see: CERN Docker images for information.

Building layered image using CERN base image

For full documentation about building images please refer to Docker documentation. Docker session below shows only how to build/push a simple layered image.

  • Pull base image from registry:
       # docker pull gitlab-registry.cern.ch/linuxsupport/cc7-base:latest
       Trying to pull repository gitlab-registry.cern.ch/linuxsupport/cc7-base ...
       latest: Pulling from gitlab-registry.cern.ch/linuxsupport/cc7-base
    
       22410711ca61: Pull complete
       Digest: sha256:0f46754cf3cd57311c3242bcc6ab2325255a33674323f2163e2ba8ac605eb771
       Status: Downloaded newer image for gitlab-registry.cern.ch/linuxsupport/cc7-base:latest
     
  • List images:
       # docker images
       REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
       gitlab-registry.cern.ch/linuxsupport/cc7-base   latest              d448f62dd7c4        13 days ago         466.5 MB
     
  • Create a Dockerfile in subdirectory:
       # mkdir cc7-test; cd cc7-test
       # vim Dockerfile
     
    containing:
       FROM gitlab-registry.cern.ch/linuxsupport/cc7-base:latest
       MAINTAINER Your Name 
       RUN yum -y update && yum -y groupinstall "Development Tools"
     
  • Start build:
       docker build -t cc7-test:20160921 .
       Sending build context to Docker daemon 2.048 kB
       Step 1 : FROM gitlab-registry.cern.ch/linuxsupport/cc7-base:latest
        ---> d448f62dd7c4
       Step 2 : MAINTAINER Your Name <your.email@cern.ch>
        ---> Using cache
        ---> c587fa9f3d5d
       Step 3 : RUN yum -y update && yum -y groupinstall "Development Tools"
        ---> Running in f3422672e567
       [...]
       Resolving Dependencies
       --> Running transaction check
       [...]
       ---> Package gcc.x86_64 0:4.8.5-4.el7 will be installed
       [...]
       Installing for group install "Development Tools":
       [...]
       gcc                       x86_64    4.8.5-4.el7               base        16 M
       [...]
       Transaction test succeeded
       Running transaction
       [...]
       Installing : gcc-4.8.5-4.el7.x86_64                                    61/110
       [...]
       Verifying  : gcc-4.8.5-4.el7.x86_64                                    52/110
       [...]
       Installed:
       [...]
         gcc.x86_64 0:4.8.5-4.el7
       [...]
    
       Complete!
        ---> 17e8fa7062f9
       Removing intermediate container f3422672e567
       Successfully built 17e8fa7062f9
     
  • List images:
       # docker images
       REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
       cc7-test                                        20160921            17e8fa7062f9        36 seconds ago      1.139 GB
       gitlab-registry.cern.ch/linuxsupport/cc7-base   latest              d448f62dd7c4        13 days ago         466.5 MB
     
  • Test your image:
       # docker run -t -i cc7-test:20160921 /bin/bash
       [root@41b570bb00c6 /]# gcc -v
       Using built-in specs.
       COLLECT_GCC=gcc
       COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
       Target: x86_64-redhat-linux
       Configured with: ../configure --prefix=/usr --mandir=/usr/share/man [...] --build=x86_64-redhat-linux
       Thread model: posix
       gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
       [root@41b570bb00c6 /]# exit
       exit
     
  • Tag the image:
       # docker tag 17e8fa7062f9 gitlab-registry.cern.ch/{group/}/cc7-test:20160921
     
  • And push it to registry (note: the registry must be preconfigured in GitLab first):
       # docker login gitlab-registry.cern.ch
       Username: YourLogin
       Password: YourPassword
       Login Succeeded
    
       # docker push gitlab-registry.cern.ch/{group/}/cc7-test:20160921
       The push refers to a repository [gitlab-registry.cern.ch/{group/}/cc7-test]
       bb0a2cef5136: Pushed
       b4b009d318b0: Pushed
       test: digest: sha256:36b189ba983f1f095f193c4a4e67c0e0b429b1018ecec2d91efa6a7369e7ca21 size: 743