Install Docker (CE) on Linux Mint (Ubuntu)

  1. Update apt package index.

    $ sudo apt update
    
  2. Install required packages.

    $ sudo apt install apt-transport-https ca-certificates curl gnupg-agent
    $ software-properties-common
    
  3. Add Dockers official GPG key.

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    

    Optional

    Verify the key with fingerprint

    $ sudo apt-key fingerprint 0EBFCD88
    

    Output should display 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 (check the last 8 digits).

  4. Add the Docker repository to your package index

    $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo "$UBUNTU_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    

    Hint

    Other Linux distributions require a different repository url (see here)

  5. Check, if the repository was added to your “additional repositories list”

    $ cat /etc/apt/sources.list.d/docker.list
    

    The output should contain something like this:

    deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
    
  6. Install docker components

    $ sudo apt update
    $ sudo apt install docker-ce docker-ce-cli docker-compose containerd.io
    

    Optional

    Access docker without using ‘sudo’

    In order to access docker without the ‘sudo’ command, your current user must be added to the docker group (was created during installation)

    $ sudo usermod -aG docker $USER
    

    Then, log out and re-log in to apply the changes

  7. Create an account on Docker Hub.

  8. Add your Docker Hub login to your docker installation

    $ docker login
    

    Optional

    A warning message may appear:

    WARNING! Your password will be stored unencrypted in /home/<USERNAME>/.docker/config.json.
    

    Install and setup docker-credential-helper to not leave your credentials unencrypted.

    1. Install pass and gnupg2:

      $ sudo apt install pass gnupg2
      
    2. Create a key pair which will be used to encrypt your password database:

      $ gpg2 --quick-gen-key <YOUR_USERNAME>
      

      Important

      In case you define a passphrase, keep it somewhere save, you will need it later.

      This will print out the public key ID (here: in red), e.g.:

      pub   rsa3072 2022-02-09 [SC] [expires: 2024-02-09]
            ECDB0435E583258DF7687798042565C64AF26E7D:
      uid                      arne.wohletz
      sub   rsa3072 2022-02-09 [E]
      

      You can reprint it by running gpg2 --list-keys.

    3. Ensure, that the primary key is trusted:

      $ gpg --edit-key <YOUR_PUBLIC_KEY_ID>
      
      gpg> trust
      gpg> 5
      gpg> quit
      
    4. Set up pass:

      $ pass init gpg2 <YOUR_PUBLIC_KEY_ID>
      $ pass insert docker-credential-helpers/docker-pass-initialized-check
      

      You should be prompted twice to enter your Docker Hub password.

    5. Download latest release of docker-credential-pass (utilizes pass)

    6. Extract the binary into a directory listed in PATH.

    7. Open your docker config file:

      $ nano ~/.docker/config.json
      
    8. Erase all content (if any) and add:

      {
          "credsStore": "pass"
      }
      

      Save and close the file.

    9. Log into Docker Hub:

      $ docker login --username="<YOUR_DOCKER_HUB_USERNAME" docker.io
      

      Enter your password (this should not be required once).

    10. Check if docker-credential-pass saved the login:

      $ docker-credentials-pass list
      

      which should print something like this:

      {"https://index.docker.io/v1/":"<YOUR_DOCKER_HUB_USERNAME>"}
      
  9. Check installation success

    $ docker run --rm -it --name test alpine:latest /bin/sh
    
    • Output should be, that alpine:latest isn’t found and is downloaded

    • Entering alpine shell after installation

    Enter this into the alpine shell:

    $ cat /etc/os-release
    

    which should output the alpine distribution info.

    Type exit to close the connection.

Sources:

https://docs.docker.com/engine/install/ubuntu https://computingforgeeks.com/install-docker-docker-compose-on-linux-mint https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo