Reputation: 5010
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.
Upvotes: 6
Views: 1880
Reputation: 735
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 '
Upvotes: 0
Reputation: 1731
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
Upvotes: 8