How to run experimental Docker features on CircleCI
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 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"'\'' &gt;&gt; /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/myimage