Install Docker on Proxmox 4
Proxmox 4 is based on Debian Jessie. Reference for this install: https://docs.docker.com/engine/installation/linux/debian/#/install-using-the-repository
Add the Docker repo for Debian Jessie
$ apt-get install curl $ curl -fsSL https://apt.dockerproject.org/gpg | apt-key add - $ echo "deb https://apt.dockerproject.org/repo/ debian-jessie main" > /etc/apt/sources.list.d/docker.list $ apt-get update
$ apt-get install docker-engine
Switch to the ZFS Storage Driver
If you installed Proxmox 4 using the ZFS filesystem (and why wouldn't you), you should switch Docker to use ZFS for its images and containers.
Check the storage engine
We want Docker to be using the ZFS storage engine. This enables very efficient use of ZFS snapshots and clones for Docker images and volumes. See https://docs.docker.com/engine/userguide/storagedriver/zfs-driver/.
If the answer to the following command is "zfs", ignore the rest of this section. If the answer is "aufs" or any other filesystem, continue on to switch the storage driver to ZFS.
$ docker info|grep Storage Storage Driver: aufs
Create the ZFS dataset for Docker
$ service docker stop $ rm -rf /var/lib/docker $ zfs create -o mountpoint=/var/lib/docker rpool/docker
Tell Docker to use the ZFS storage driver
Docker should detect ZFS and automatically use the ZFS storage driver. However, I found that I had to add the
--storage-driver=zfs option explicitly.
Note that since Proxmox 4 uses systemd, /etc/defaults/docker is ignored. Setting DOCKER_OPTS there is ineffective.
For reference, I read this on Docker with systemd: https://docs.docker.com/engine/admin/systemd/
Create a directory for the config file override:
$ mkdir /etc/systemd/system/docker.service.d
Create a file called
/etc/systemd/system/docker.service.d/storage-driver.conf with the contents:
[Service] ExecStart= ExecStart=/usr/bin/dockerd --storage-driver=zfs -H fd://
Then run to reload the service config files:
$ systemctl daemon-reload
Start the docker service and check the storage engine
The answer should now be "zfs" instead of "aufs".
$ service docker start $ docker info|grep Storage Storage Driver: zfs
Test the Docker install
Run the hello_world image
This runs the hello world image to verify that Docker is running properly.
$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
List the new hello_world container and image
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 48b5124b2768 5 weeks ago 1.84 kB $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 16f1e50f69be hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago musing_mirzakhani
Show that new ZFS datasets have been created
$ zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 327G 3.19T 128K /rpool rpool/ROOT 12.2G 3.19T 128K /rpool/ROOT rpool/ROOT/pve-1 12.2G 3.19T 12.2G / rpool/data 306G 3.19T 128K /rpool/data rpool/docker 879K 3.19T 543K /var/lib/docker rpool/docker/1610e55c639dadcb48c89a3f686f7251571fa68d157bf900c32cedbccc7a307f 85.2K 3.19T 144K legacy rpool/docker/1610e55c639dadcb48c89a3f686f7251571fa68d157bf900c32cedbccc7a307f-init 117K 3.19T 144K legacy rpool/docker/6a3fbc4db9eb44757209fbec08d4873f45d512ffef83fcc3ddd6ef4a8ad79968 133K 3.19T 133K legacy rpool/swap 8.50G 3.20T 5.53M -