Posted by : at

Category : devops   linux   docker   ubuntu

Installing Docker CE in Ubuntu 18.04 LTS

Method: 1 - using Repository

Step 1. Update Software Repositories

$ sudo apt-get update

Step 2. Uninstall Old Versions

$ sudo apt-get remove docker docker-engine docker.io

Step 3. Install Dependencies

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Step 4. Add Docker’s official GPG Key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 5.

Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint

$ sudo apt-key fingerprint 0EBFCD88

Step 6. Add Stable Repository

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Step 7. Update the apt package index:

$ sudo apt-get update

Step 8. Install the latest version of Docker CE or go to the next step to install a specific version. Any existing installation of Docker is replaced.

$ sudo apt-get install docker-ce

(Optional): Install Specific Version of Docker List the available versions of Docker by entering the following in a terminal window:

apt-cache madison docker-ce

if you want to install a particular version of docker-ce

$ sudo apt-get install docker-ce=<VERSION>

Step 9. Verify that Docker CE is installed correctly by running the hello-world image

$ sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

You should see a “Hello from Docker”. If so, Docker is successfully installed.

Step 10. If you want to Uninstall Docker CE

Uninstall the Docker CE package:

$ sudo apt-get purge docker-ce

Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

$ sudo rm -rf /var/lib/docker

You must delete any edited configuration files manually.

Related Posts