2020-12-02

How to use Docker on Linux amd64 without installing it

This blog post explains how to download and use Docker on Linux amd64 without installing it, and how to clean up afterwards. It complements the official instructions, and contains some copy-pasteable commands.

You will need to start dockerd as root, so we assume that you can run commands as root with sudo.

Visit https://download.docker.com/linux/static/stable/x86_64/, and choose a Docker version. For example, we will use 17.12.1-ce . Download it by running the following command:

$ (V=17.12.1-ce; mkdir "$HOME/Downloads/docker-$V" &&
  cd "$HOME/Downloads/docker-$V" &&
  wget -qO- "https://download.docker.com/linux/static/stable/x86_64/docker-$V.tgz" |
  tar xzv)

If you are using Ubuntu 14.04, you need to install a few small packages:

$ sudo apt-get install cgroup-lite aufs-tools  # Only on Ubuntu 14.04.

(cgroup-lite fixes the Error starting daemon: Devices cgroup isn't mounted error, and aufs-tools fixes the Couldn't run auplink before unmount warning. Optionally, see this answer on fixing the Module br_netfilter not found warning.)

In a new terminal window, start dockerd, and keep it running:

$ sudo env PATH="$HOME/Downloads/docker-17.12.1-ce/docker:$PATH" dockerd

Run this to fix permission issues connecting to /var/run/docker.sock:

$ sudo chgrp sudo /var/run/docker.sock

In each terminal window where you want to run docker commands, run this first:

$ export PATH="$HOME/Downloads/docker-17.12.1-ce/docker:$PATH"

Run this to test that everything is working (it will take a few seconds for the first time):

$ docker run --rm -it hello-world

Now you can run docker commands as usual.

To stop dockerd, press Ctrl-C in the terminal window it is running in, or run this:

$ sudo fuser -k -TERM /var/run/docker.sock

If there are some containers running, dockerd tries to kill them, and waits for 15 seconds. To avoid that delay, you can manually kill them (either before or after stopping dockerd):

$ (P=; test -e /var/run/docker.sock &&
        sudo chgrp sudo /var/run/docker.sock && P="$(docker ps -aq)";
        test "$P" && docker kill $P)

To delete Docker (including images and configuration), first stop dockerd, then run:

$ sudo rm -rf /etc/docker /var/lib/docker /var/run/docker /var/run/docker.*