Docker is an open-source project that automates the deployment of applications inside software containers. Here is Docker quick start guide on Ubuntu Linux. We’ll use Ubuntu 14.04.2 LTS for the purpose of this tutorial.
- Add pgp key
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
-
Update apt sources
## On Ubuntu Trusty 14.04 (LTS) $ sudo sh -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list" ## On Ubuntu Vivid 15.04 $ sudo sh -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-vivid main' > /etc/apt/sources.list.d/docker.list" ## Ubuntu Wily 15.10 $ sudo sh -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-wily main' > /etc/apt/sources.list.d/docker.list"
- Install docker and start the docker service
$ sudo apt-get install docker-engine $ sudo service docker start
-
To validate id docker is running:
$ sudo docker run hello-world
- Pull latest ubuntu image
docker pull ubuntu Using default tag: latest latest: Pulling from library/ubuntu 92ec6d044cb3: Pull complete 2ef91804894a: Pull complete f80999a1f330: Pull complete 6cc0fc2a5ee3: Pull complete Digest: sha256:457b05828bdb5dcc044d93d042863fba3f2158ae249a6db5ae3934307c757c54 Status: Downloaded newer image for ubuntu:latest
- Run ubuntu bash in docker and create container named ubuntu1
$ sudo docker run -it --name ubuntu1 ubuntu bash
In docker ubuntu shell
$ python --version bash: python: command not found $ apt-get install python $ python --version Python 2.7.6
Verify if apt will pull from the right repository
$ apt-cache policy docker-engine
Update apt package index
$ sudo apt-get update
Note on “Cannot connect to the Docker daemon” error
If you get this error:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
This could be due to current user not being in docker group. If you run docker command with sudo this may not happen. In long term, you should add the user to docker group.