Installing Docker on ubuntu 18.04

This tutorial assumes you are wanting to install docker, onto the Ubuntu 18.04 OS

  1. Update the packages database

    • This is done by executing sudo apt-get update, this makes sure your ubuntu installation has record of the current revisions for any software we would like to install.
  2. Remove/uninstall any old docker installations

    • Next we’re going to execute this command sudo apt-get remove docker docker-engine docker.io to make sure any old docker installations are removed so we can cleanly install the latest version of Docker
  3. Installing docker.io via the repository

    • Now we just execute the command sudo apt-get install docker.io, followed by pressing Enter (optionally y as well for yes) once we are asked to confirm whether we would like to install it or not.
  4. Setting up Docker

    • The purpose of setting it up is so that when your machine restarts, it will as well boot up any docker containers that are setup.
    • For this, we must run 2 commands one after another: sudo systemctl start docker and sudo systemctl enable docker.
  5. Checking dockers installed version (Optional)

    • To check the docker version and to make sure its up and running, we execute the command docker --version, which should result in something like this: Capture
  • Note: If you would like to install a specific version of docker, check out below, as it describes exactly how to do that.

  • Alternative: Install Docker from Official Repository (Even a specific version)

    1. Again, we make sure Ubuntu has the latest revisions of software: sudo apt-get update
    2. Now you’ll need to install a few dependencies to make sure that your machine can actually connect to the docker repository and install any version that you prefer.
      • sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    • Now if you are wondering if what each of these packages does, read below:
      • apt-transport-https: Allows the package manager to transfer files and data over https
      • ca-certificates: Allows the system (and web browser) to check security certificates
      • curl: This is a tool for transferring data
      • software-properties-common: Adds scripts for managing software
    1. Now to make sure the software we install from their repository is authentic, we can install their PGP key:
      • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
    2. Time to install dockers repository so we can download and install the software we are requesting:
      • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
        • The $(lsb_release -cs) command, scans and returns your machines codename for the version of Ubuntu you have installed, ie: bionic (18.04)
    3. Since we have done all that, it is time to update the repositories again, so that we can track all the Docker versions we get from the docker repository: sudo apt-get update
    • Here is where you decide: Install the latest version, or a specific version:
      • Latest version:
      1. Simply run the command: sudo apt-get install docker-ce
      • Specific version:
      1. List all docker versions contained within the repository for ubuntu 18.04: apt-cache madison docker-ce It should look something along the lines of this:
      2. Now using the command sudo apt-get install docker-ce=<VERSION> Substitue <VERSION> with the version we are looking for, I have highlighted them in yellow on the screenshot so its easy to identify them.
      3. (Optionally) Type in docker --version to make sure you have installed the version you are looking for.

And there you go, you can now go and enjoy your installed version of docker. :grin:

  • More how-to’s arriving soon, so keep coming back if you are interested.
1 Like

According to this: https://docs.docker.com/install/linux/docker-ce/ubuntu/ the official site does support Ubuntu 18.04

Well thats good :smiley: