How to run docker with experimental functions on Ubuntu 16.04
Asked Answered
A

6

42

I have following question:

How to run docker with experimental features on (like image squashing docker build --squash=true... for reduce it size) on ubuntu 16.04 ?

Auspex answered 3/6, 2017 at 16:47 Comment(0)
A
93

To turn on experimental docker functions create following file by:

sudo nano /etc/docker/daemon.json

and add below content to it

{ 
    "experimental": true 
} 

and save file (by CTRL+X and Enter ) and exit. In terminal type:

sudo service docker restart

To check that experimental funcions are ON, type in terminal:

docker version

And you should see Experimental: true

UPDATE

Instead of nano you can use this one-liner:

echo $'{\n    "experimental": true\n}' | sudo tee /etc/docker/daemon.json
Auspex answered 3/6, 2017 at 16:47 Comment(4)
Note the limitations of that one-liner update: It's trying to 'append' however if you actually already have a config file, it will break the file format.Spradling
sudo sh -c 'echo "$(cat /etc/docker/daemon.json) {\"experimental\": true}" |jq -s add |sponge /etc/docker/daemon.json && service docker restart'Election
fyi- to enable this for the client, the config file to create is ~/.docker/config.json and the value is "enabled", not trueElectromagnetism
Not sure, but I think sudo service docker restart will shut down any docker containers running, just be carefulEntozoon
P
18

I tried everything here on a Ubuntu 18.04 VM on my mac--nothing worked. All over the interwebs said the same thing, but the one thing that finally got experimental turned on was @Michael Haren's tiny answer:

fyi- to enable this for the client, the config file to create is ~/.docker/config.json and the value is "enabled", not true

which meant something like this for me:

$ mkdir ~/.docker
$ echo '{ "experimental": "enabled" }' > ~/.docker/config.json
$ sudo systemctl restart docker
$ docker version
  ...
  Experimental: true
  ...

This should be a top-level answer. So, credit to them (except sweet internet karma points for me...).

Pushball answered 24/3, 2020 at 20:23 Comment(3)
This unfortunately did not work on Ubuntu 20.04, @Kamil's answer did however.Janeanjaneczka
Note that the OP specified 16.04, so it may work in 16.04 or possibly was working at the time the answer was posted in 03/2020.Janeanjaneczka
This is the top answer!Geographical
S
10

If you only want to run it temporarily / without modifying files, you can export DOCKER_CLI_EXPERIMENTAL=enabled. The below turns on experimental mode for your client.

$ docker version
 Experimental:      false
$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ docker version
 Experimental:      true
Sami answered 31/3, 2020 at 1:39 Comment(0)
B
2

Posting this to help those who are running docker on macOS

You will need to enable experimental on two files, one is client while another is docker engine

I suggest open the file manually instead of direct echo into the file as that file might have some other configuration and you might not want to overwrite them accidentally

For client, visit ~/.docker/config.json, and add "experimental": "enabled" on top level config as below

{
  "experimental" : "enabled",
  "auths" : {
    "harbor.xxx.com" : {

    }
  },
  "credsStore" : "desktop"
}

For Docker Engine, visit ~/.docker/daemon.json and add "experimental": true on top level config as below

{
  "features": {
    "buildkit": true
  },
  "experimental": true,
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  }
}

Do note that the "value" of experimental is different between client and server.

Once done, restart the docker using command below

killall Docker && open /Applications/Docker.app

then verify the result

docker version
Barbarize answered 14/9, 2021 at 3:24 Comment(0)
K
2

I think you can solve this on Linux using the systemctl as described by https://mcmap.net/q/382038/-how-to-run-docker-with-experimental-functions-on-ubuntu-16-04 on this SO. However, first you need to edit the correct files... Here's the way to set it up in a MacOS if you were looking for similar answers.

Docker run with Experiments MacOS

  • Just set the variable ENABLED=true or ENABLED=false and this script will automagically turn it on or off, writing to the file

NOTE: You MUST have jq installed to execute and update in-place.

ENABLED=true; \

CONFIG=~/.docker/config.json; DAEMON=~/.docker/daemon.json ; \

cat <<< $(jq --argjson V ${ENABLED} '.experimental = $V' ${DAEMON}) > ${DAEMON} ; \
cat <<< $(jq --arg V $(if [ "${ENABLED}" = "true" ]; then echo "enabled"; else echo "disabled"; fi) '.experimental = $V' ${CONFIG}) > ${CONFIG} ; \ 

cat ~/.docker/config.json ; \
cat ~/.docker/daemon.json

Output confirmation

  • This will be output automatically confirming
{
  "auths": {
    "https://index.docker.io/v1/": {},
    "registry.gitlab.com": {}
  },
  "credsStore": "desktop",
  "experimental": "enabled",
  "currentContext": "default"
}
{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": true,
  "features": {
    "buildkit": true
  }
}

Restart Docker Engine in MacOS

  • Just run the following
killall Docker && open /Applications/Docker.app

References

Koeninger answered 15/2, 2022 at 8:11 Comment(0)
O
1
sudo sed -i 's/ExecStart=\/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock/ExecStart=\/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock --experimental/g' /lib/systemd/system/docker.service
sudo systemctl daemon-reload
sudo systemctl restart docker
Orbicular answered 23/12, 2021 at 10:29 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Erosive

© 2022 - 2024 — McMap. All rights reserved.