Installing Docker and Ubuntu Image shell

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 cocker, 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-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

The Docker daemon starts automatically. You can verify it as,

ps -ax | grep docker

24946 ? Ssl 0:11 /usr/bin/dockerd –raw-logs
24958 ? Ssl 0:01 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock –metrics-interval=0 –start-timeout 2m –state-dir /var/run/docker/libcontainerd/containerd –shim docker-containerd-shim –runtime docker-runc

READ  how initrd is mounted by linux kernel

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

sudo docker run hello-world

Now to install new ubuntu image, and going to shell, type below command,

sudo docker run -it ubuntu bash

This will take you to new shell, where you can work as needed, and exit using below command,

 root@4feb8fa6f496:/# exit 

You can check which images has been installed as,

$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 6a2f32de169d 35 hours ago 117 MB
hello-world latest 48b5124b2768 3 months ago 1.84 kB
$ sudo docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b4ceb96c87b ubuntu "/bin/bash" About a minute ago Exited (0) About a minute ago peaceful_euler

Start docker container,

sudo docker container start 3b4ceb96c87b
3b4ceb96c87b 

This will start docker with basic ubuntu.

Leave a Reply

Your email address will not be published. Required fields are marked *