Friday, September 19, 2014

Installing docker (not so obvoius)

I was trying to explore docker (mainly to see and understand if docker would be a better choice for my project ..currently i am using vagrant ) and the first step was to install docker.

and something unexpected happened


so my steps were:-
1. install docker  (this turned out to be wrong docker)

sudo apt-get install docker
2. run the first command from the tutorial ( i doubled checked multiple tutorials to make sure the command was right )
sudo docker run -t -i ubuntu:14.04 /bin/bash

3. but things were not working ..It could not recognise the flags (-t, -i)  hence started the troubleshooting ( you generally don't expect to run into issues on the first command..)

after some debugging i found that IT IS THE WRONG DOCKER!!! ( imagine that :))


more details here :-
http://stackoverflow.com/questions/20018736/docker-opens-up-a-tiny-new-window-that-does-nothing


anyways what i did was ultimately

4. remove unwanted docker (you can verify that its the unwanted on by coker --help)
 docker --help  
 sudo apt-get remove docker


5. now if you have ubuntu 14:0 then this should work :-
$ sudo apt-get update
$ sudo apt-get install docker.io
$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
$ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io 
6. But if you have an older ubuntu these instructions will help :-

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D8576A8BA88D21E9  
 $ sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"  
 $ sudo apt-get update  
 $ sudo apt-get install lxc-docker  
 $ sudo docker version  
 Client version: 0.9.0  
 Go version (client): go1.2.1  
 Git commit (client): 2b3fdf2  
 Server version: 0.9.0  
 Git commit (server): 2b3fdf2  
 Go version (server): go1.2.1  
 Last stable version: 0.9.0  
 $ sudo docker search ubuntu | grep '^ubuntu'  
 ubuntu   General use Ubuntu base image. Tags availa...  108  
 ubuntu-upstart                       0  
 ubuntu/ping 
 
 
 
7. to know things are working ... you should see something like this:- 
 0  
root@njain2:~/office/projects# sudo docker run -t -i ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
Pulling repository ubuntu
96864a7d2df3: Error pulling image (14.04) from ubuntu, endpoint: https://registry-196864a7d2df3: Error pulling image (14.04) from ubuntu, Error mounting '/dev/mapper/docker-202:2-1501557-511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158' on '/var/lib/docker/devicemapper/mnt/511136ea3c5a64f264b78b5433614aec563103b4d42014/09/19 12:55:20 Error pulling image (14.04) from ubuntu, Error mounting '/dev/mapper/docker-202:2-1501557-511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158' on '/var/lib/docker/devicemapper/mnt/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158': device or resource busy
root@njain2:~/office/projects# pwd
/root/office/projects
root@njain2:~/office/projects# cd event-notification/ 



8. In case things are not working (due to device mapper errors) 
use AUFS instead of device mapper ( you can detect this by "sudo docker info"
$ sudo apt-get update
$ sudo apt-get install linux-image-extra-`uname -r`
$ sudo apt-get purge --auto-remove lxc-docker 
$ sudo apt-get install lxc-docker
$ buzzenv)njain@njain3:~/office/buzz$ sudo docker info
Containers: 1
Images: 7
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 9
Execution Driver: native-0.2
Kernel Version: 3.2.0-60-virtual
Operating System: Ubuntu precise (12.04.4 LTS)
you should not see device mapper in docker info :) and you are good to go 
 
 
 

No comments:

Post a Comment