snippetdockerMinor
How to run experimental Docker features on CircleCI
Viewed 0 times
experimentaldockercirclecihowfeaturesrun
Problem
When a build is started on CircleCI one of the first things that is done is:
Setup a remote Docker engine
Subsequently when
Discussion
It works to use experimental features locally after changing the
and restarting the docker systemctl service, but how to do that on CircleCI? It seems impossible as the build output indicates that a connection is made to a remote docker that reside on the CircleCI systems.
Setup a remote Docker engine
Specified reusable docker engine, but build has not been whitelisted.
Contact CircleCI to be whitelisted
Allocating a remote Docker Engine
...
Remote Docker engine created. Using VM 'prealloc-wrjtu1qd-1491949826270'
Created container accessible with:
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://:2376
DOCKER_CERT_PATH=/tmp/docker-certs615987123
DOCKER_MACHINE_NAME=51123Subsequently when
docker build --squash -t imagename . is run on CircleCI it results in:Error response from daemon: squash is only supported with experimental mode
Exited with code 1Discussion
It works to use experimental features locally after changing the
/etc/docker/daemon.json as follows:{
"experimental": true
}and restarting the docker systemctl service, but how to do that on CircleCI? It seems impossible as the build output indicates that a connection is made to a remote docker that reside on the CircleCI systems.
Solution
CircleCI now allows you to use a machine executor which provisions a separate VM for you, with Ubuntu 14.04 and Docker version 17.06.0-ce installed. This allows you to turn on experimental features for the Docker daemon.
You need to use the
You can only choose 2 images for the machine:
You'll also need to install dependencies on the machine yourself, as it is quite bare. For example, if you need PHP for your tests, you'll need to run
Here is a sample .circleci/config.yml that builds a Docker image using experimental feature
.circleci/config.yml
You need to use the
machine key instead of the docker key, to run your job in a separate virtual machine instead of just a Docker container.You can only choose 2 images for the machine:
circleci/classic:latest: Ubuntu 14.04 with Docker 17.03.0-ce, or
circleci/classic:edge: Ubuntu 14.04 with Docker 17.06.0-ce - the one with experimental features.
You'll also need to install dependencies on the machine yourself, as it is quite bare. For example, if you need PHP for your tests, you'll need to run
sudo apt-get install -y php5.Here is a sample .circleci/config.yml that builds a Docker image using experimental feature
docker build --squash:.circleci/config.yml
version: 2
jobs:
build:
# Run in a separate virtual machine instead of a Docker container.
machine:
enabled: true
# Use Ubuntu 14.04 with bleeding edge Docker daemon 17.06.0-ce.
image: circleci/classic:edge
steps:
- checkout
- run:
command: |
# Restart Docker with experimental features on.
sudo sh -c 'echo '\''DOCKER_OPTS="--experimental=true"'\'' >> /etc/default/docker'
sudo service docker restart
# Install dependencies for tests etc.
sudo apt-get update
sudo apt-get install -y php5
# Build image with experimental feature --squash.
docker build --squash -t myuser/myimage .
# Login and push Docker image to registry.
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push myuser/myimageCode Snippets
version: 2
jobs:
build:
# Run in a separate virtual machine instead of a Docker container.
machine:
enabled: true
# Use Ubuntu 14.04 with bleeding edge Docker daemon 17.06.0-ce.
image: circleci/classic:edge
steps:
- checkout
- run:
command: |
# Restart Docker with experimental features on.
sudo sh -c 'echo '\''DOCKER_OPTS="--experimental=true"'\'' >> /etc/default/docker'
sudo service docker restart
# Install dependencies for tests etc.
sudo apt-get update
sudo apt-get install -y php5
# Build image with experimental feature --squash.
docker build --squash -t myuser/myimage .
# Login and push Docker image to registry.
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push myuser/myimageContext
StackExchange DevOps Q#849, answer score: 8
Revisions (0)
No revisions yet.