The steps below shows how to install docker on x86_64 bit Ubuntu desktop and have independent Ubuntu shell inside docker.
[ Note: docker works only with 64 bit Ubuntu, hence if you have 32 bit Ubuntu machine, it will not work ]
If you have any nonworking traces of docker, remove it using below command,
$ sudo apt-get remove docker docker-engine
Type below commands on your Ubuntu terminal,
$ sudo apt-get update
$ sudo apt install docker.io
above command will install docker command, you can check using “which docker” command and you would see it installed as /usr/bin/docker
Next we need to install docker engine “docker-ce” as,
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Add Docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88 pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <email@example.com> sub rsa4096 2017-02-22 [S]
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get update
Now, you can verify that docker-ce package is available to install as,
$ sudo apt search docker-ce Sorting... Done Full Text Search... Done docker-ce/bionic 5:19.03.13~3-0~ubuntu-bionic amd64 Docker: the open-source application container engine docker-ce-cli/bionic 5:19.03.13~3-0~ubuntu-bionic amd64 Docker CLI: the open-source application container engine
Now, lets check if there is any docker image currently running, which can be checked as,
$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
As, you can see above everything is empty, means no image is currently installed..
Now, install the package as,
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
above command will install docker engine and start the service which can be verified as,
$ ps -ax | grep docker 2188 ? Ssl 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Verify that Docker is installed correctly by running the hello-world image.
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pull complete Digest: sha256:8c5aeeb6a5f3ba4883347d3747a7249f491766ca1caa47e5da5dfcf6b9b717c0 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
as you see, it pulled the “hello-world” docker image and installed and run this to show the message “Hello from Docker !” which shows you have successfully installed docker on your ubuntu machine.
You can see the “hello-world” docker image installed as,
$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest bf756fb1ae65 9 months ago 13.3kB