6
votes

I want to be able to use the --squash switch when building docker images as this shaves several MB of the result image.

This requires experimental features enabled for docker.

Executing a docker --version confirms (as it should) experimental features to be off on hosted Azure Pipelines agents.

Server:
 Engine:
  Version:  18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:    Thu Apr 26 07:15:30 2018
  OS/Arch:  linux/amd64
  Experimental: false

Linux agents are running

Kernel Version: 4.15.0-1022-azure
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64

I've tried altering /etc/systemd/system/docker.service.d/docker.conf and /etc/docker/daemon.json to start with/include experimental flags, but didn't succeed in enabling it.

docker.conf

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// --experimental=tr

or

daemon.json

{ 
    "experimental": true 
} 

But don't unsure if I can restart the daemon on a hosted agent.

Currently doing yaml builds invoking docker from bash, but didn't see anything around experimental in the web interface either.

If i spin up my own Ubuntu VM and host an agent on that, experimental works, but want to avoid cost and maintenance by using the hosted agents.

2
Experimental flag works well in Ununtu VM but not on host? Could u plz add up your daemon.json file?Light.G
Added the example files, but think issue is that the Azure Pipelines Hosted Agent won't let me restart the daemon, so there might be some other way needed to turn on experimental mode. On my own machines it works fine, but there I've got full control over the machine.devlead
Without restarting docker daemon, I don’t think it would work. But according to your info above, you have wrongly configured in docker.conf. Just —-experimental is enough, no ‘=true’ needed.Light.G

2 Answers

8
votes

In the Ubuntu Image you can simply restart the docker service, after the daemon.json is updated. I use a script with two lines:

echo '{ "experimental": true }' | sudo tee /etc/docker/daemon.json
sudo service docker restart
0
votes

Enabled it using the following script before the docker build task in my pipeline.

- script: |
      echo '{ "experimental": true }' | sudo tee /etc/docker/daemon.json
      sudo service docker restart
  displayName: 'Enable docker experimental features for squashing '