As already mentioned, this is the most straightforward installation out of the three systems we will be looking at. To install Docker, simply run the following command from a Terminal session:
$ curl -sSL https://get.docker.com/ | sh
$ sudo systemctl start docker
You will also be asked to add your current user to the Docker group. To do this, run the following command, making sure you replace the username with your own:
$ sudo usermod -aG docker username
These commands will download, install, and configure the latest version of Docker from Docker themselves. At the time of writing, the Linux operating system version installed by the official install script is 18.06.
Running the following command should confirm that Docker is installed and running:
$ docker version
You should see something similar to the following output:
There are two supporting tools that we are going to use in future chapters, which are installed as part of the Docker for macOS or Windows 10 installers.
To ensure that we are ready to use these tools in later chapters, we should install them now. The first tool is Docker Machine. To install this, we first need to get the latest version number. You can find this by visiting the releases section of the project's GitHub page at https://github.com/docker/machine/releases/. At the time of writing, the version was 0.15.0—update the version number in the commands in the following code block with whatever the latest version is when you install it:
$ MACHINEVERSION=0.15.0
$ curl -L https://github.com/docker/machine/releases/download/v$MACHINEVERSION/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine
$ chmod +x /tmp/docker-machine
$ sudo mv /tmp/docker-machine /usr/local/bin/docker-machine
To download and install the next and final tool, Docker Compose, run the following commands, again checking that you are running the latest version by visiting the releases page at https://github.com/docker/compose/releases/:
$ COMPOSEVERSION=1.22.0
$ curl -L https://github.com/docker/compose/releases/download/$COMPOSEVERSION/docker-compose-`uname -s`-`uname -m` >/tmp/docker-compose
$ chmod +x /tmp/docker-compose
$ sudo mv /tmp/docker-compose /usr/local/bin/docker-compose
Once it's installed, you should be able to run the following two commands confirm the versions of the software is correctly:
$ docker-machine version
$ docker-compose version