lost and found ( for me ? )

Showing posts with label vagrant.. Show all posts
Showing posts with label vagrant.. Show all posts

install docker on Ubuntu 14.04 running within virtualbox

Here are trial and error logs when installing docker on Ubuntu 14.04 which is running within virtualbox as a virtual machine.

I used vagrant to prepare VMs for docker testing environment.
I already downloaded some boxes in my machine and used trusty64(virtualbox).
$ vagrant box list
centos60      (virtualbox, 0)
coreos-alpha  (virtualbox, 752.1.0)
coreos-stable (virtualbox, 717.3.0)
trusty64      (libvirt, 0)
trusty64      (virtualbox, 0)

initialize a new vagrant environment for docker testing environment.
$ vagrant init trusty64

Here is a Vagrantfile.
I prepared two VMs for a clustering test( I will evaluate that later)  and each VM has three vNICs.
$ cat Vagrantfile
Vagrant.configure(2) do |config|
 config.vm.box = "trusty64"
 config.vm.provider "virtualbox" do |v|
   v.memory = 2048
   v.cpus = 1
 end

 config.vm.define :ubuntu01 do |ubuntu01|
   ubuntu01.vm.hostname = "ubuntu01"
   ubuntu01.vm.network :private_network, ip: "192.168.33.10"
   ubuntu01.vm.network :private_network, ip: "192.168.34.10"
   ubuntu01.vm.network :private_network, ip: "192.168.35.10"
 end

 config.vm.define :ubuntu02 do |ubuntu02|
   ubuntu02.vm.hostname = "ubuntu02"
   ubuntu02.vm.network :private_network, ip: "192.168.33.20"
   ubuntu02.vm.network :private_network, ip: "192.168.34.20"
   ubuntu02.vm.network :private_network, ip: "192.168.35.20"
 end
end

start the VMs
$ vagrant up

$ vagrant status
Current machine states:

ubuntu01                  running (virtualbox)
ubuntu02                  running (virtualbox)

access to the “ubuntu01” VM
$ vagrant ssh ubuntu01


vagrant@ubuntu01:~$ ifconfig -a | grep 192
         inet addr:192.168.33.10  Bcast:192.168.33.255  Mask:255.255.255.0
         inet addr:192.168.34.10  Bcast:192.168.34.255  Mask:255.255.255.0
         inet addr:192.168.35.10  Bcast:192.168.35.255  Mask:255.255.255.0

install docker within this virtual machine(ubuntu01).
vagrant@ubuntu01:~$ sudo apt-get update

vagrant@ubuntu01:~$ sudo apt-get install docker.io

vagrant@ubuntu01:~$ docker --version
Docker version 1.0.1, build 990021a

docker.io is a symbolic link file of docker.
Googling docker installation tutorials, it seems that we need to create a symbolic link manually, however, in my case, I do not need to do that.
The symbolic link was created automatically.
vagrant@ubuntu01:~$ ls -l /usr/bin/docker*
-rwxr-xr-x 1 root root 15240483 Aug 21  2014 /usr/bin/docker
lrwxrwxrwx 1 root root        6 Aug 21  2014 /usr/bin/docker.io -> docker

confirm docker is running as a background process.
vagrant@ubuntu01:~$ sudo service docker.io status
docker.io start/running, process 26735

start docker.io when a server boots up.
vagrant@ubuntu01:~$ sudo update-rc.d docker.io defaults

download a docker container
vagrant@ubuntu01:~$ sudo docker pull ubuntu

run a docker container.
vagrant@ubuntu01:~$ sudo docker run -i -t ubuntu /bin/bash
root@84bf7f3be749:/#

open another terminal
list containers running.
vagrant@ubuntu01:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
84bf7f3be749        ubuntu:14.04        /bin/bash           About a minute ago   Up About a minute                       furious_curie       
vagrant@ubuntu01:~$

stop the container
vagrant@ubuntu01:~$ sudo docker stop 84bf7f3be749
84bf7f3be749

vagrant@ubuntu01:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
vagrant@ubuntu01:~$

Reference
http://www.liquidweb.com/kb/how-to-install-docker-on-ubuntu-14-04-lts/