Docker

From Grid5000
Jump to: navigation, search


Docker is a software technology that provides operating-system-level virtualization. In this page, we present some tools that are specifically designed to use Docker on Grid'5000.

Installing Docker from a node

You can install and use Docker from a node with the standard environment by following these instructions:

Reserve a node
Terminal.png fnancy:
oarsub -I

(you can also use option -t deploy and Kadeploy if you prefer)

Install Docker

The script g5k-setup-docker, available from the standard environment, installs Docker locally and make Docker commands available without user needing to log out (by giving read write permissions to the file /var/run/docker.sock)

Terminal.png node:
sudo-g5k env PATH="$PATH" g5k-setup-docker

g5k-setup-docker can also call sudo-g5k internally, so it is possible to simply type

Terminal.png node:
g5k-setup-docker

If you want to simply install Docker, without changing the permissions of /var/run/docker.sock (note that in this case you must log out and reconnect before using Docker commands), you can type

Terminal.png node:
g5k-setup-docker -i
Run Docker

You can now check that Docker is up and running

Terminal.png node:
docker run hello-world
Note for the environments nfs and big

In addition to the standard environment, g5k-setup-docker works with the environments debian9-x64-nfs and debian9-x64-big (but not with the environments jessie-x64-nfs and jessie-x64-big). Note that the directory containing g5k-setup-docker is not defined in the $PATH of these environments: you must so call the script from its full path /grid5000/code/bin/g5k-setup-docker.

Using docker-machine and docker-g5k

The Spirals Team in Lille developped two tools to ease Docker usage on Grid'5000:

  • a docker-machine driver
  • the docker-g5k program

Provision a node with docker-machine

The driver for docker-machine allows you to reserve a node on Grid'5000 and to install a Linux image and Docker Engine on it, from your computer and in one single command. The reserved node is then available from commands like docker-machine ssh (standard ssh commands don't work when nodes are reserved with docker-machine).

Create a Swarm with docker-g5k

The docker-g5k program allows you to reserve several nodes, possibly on different sites, and to install a Linux image and Docker Engine on each node, in one single command. This command configures a Swarm, i.e. a set of Docker containers distributed over several nodes that communicate with each other.

Managing Docker images

One difficult aspect of using Docker is efficient images management, as (1) it is often required to load such images on many nodes simultaneously; (2) Grid'5000 connection to the internet is limited to 1 Gbps. The following strategies are recommended to manage Docker images:

Use docker load/save

To load and save images quickly, we encourage you to use docker load and docker save commands, with .tar docker images stored in your Grid'5000 home. Users home are NFS mounted, with good network performance.

Example
Terminal.png node1:
docker pull alpine
docker save -o ~/alpine.tar alpine
Terminal.png node2:
docker load -i ~/alpine.tar
docker run -it alpine

You can also use docker load command instead of retrieving the image from Docker Hub, when deploying a Swarm with docker-g5k.

Example with docker-g5k

Give read rights to your image

Terminal.png frontend:
chmod 644 ~/alpine.tar

Deploy three Docker nodes in Nancy (activate the Grid'5000 VPN before launching this command)

Terminal.png laptop:
docker-g5k create-cluster --g5k-username "user" --g5k-password "********" --g5k-image "jessie-x64-std" --g5k-reserve-nodes "nancy:3"

Load Alpine image on each node

Terminal.png laptop:
for i in {0..2}; do docker-machine ssh nancy-${i} "docker load -i /home/user/alpine.tar"; done

Use Inria private registry

Inria members can store private Docker images at Inria private registry (also look at the documentation), but network throughput is limited to Grid'5000 external network connection.

Use a persistent VM

If you want to benefit from a private registry with good network performance, and are ready to manually install your own registry, you can request a Persistent Virtual Machine. You can look at Harbor or Portus open source projects, in order to install your own registry.