2014/07/31

docker on Linux Mint 初體驗 (resolve problem: Cannot connect to the Docker daemon. Is 'docker -d' running on this host?)


[ Quick Solution Mode ]
$  sudo docker -d                   # check docker daemon is running
# if not and you see the error message like
"stat /sbin/apparmor_parser: no such file or directory ()
[916c0d18] -job initserver() = ERR (1)"

$ sudo apt-get install apparmor     # install apparmor package
$ sudo service docker start         # start up docker service (daemon)
$ sudo docker run -i -t ubuntu /bin/bash     # it should be worked

[ Verbose Mode ]
今年 COSCUP 上一直聽到一個很火紅的東西就是 docker,
他有點像 VM ,但運作原理和速度卻跟我們一般熟悉的 VM 大不相同,
簡單利用 VM 的概念來對應 docker,
可以想像成 VMWare, VMPlayer, VirtualBox, docker 是同一層,
用來承載另一個系統,
而用 VMWare, VirtualBox 產生的 VMs, 對應 docker 則稱為 images,

而 docker 運用一些機制(lxc, cgroup, aufs...), 來作到 images 之間
能像一個 VM 一般獨立運作執行, 能擁有自己的環境空間,
且同時又是直接使用實際的硬體資源,
而不像以前的 VM 一樣只能使用預先分配的資源,
使用機制的進一步觀念請參考最下面附的連結.

既然已簡單了解 docker 是什麼,
那就趕快來跟著官方教學來 step by step 囉...

Installation steps please follow docker user guide (choose 'Ubuntu' OS)
If you try to verify the docker installation has worked, you see the message "Cannot connect to the Docker daemon. Is 'docker -d' running on this host?", you may try this...
$ sudo docker run -i -t ubuntu /bin/bash
2014/07/31 19:38:42 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
# as the user guide, try to verify that the installation has worked
# by downloading the ubuntu image and launching a container.

# Two way to check 'docker -d' is running
# way I (if running, you should see "/usr/bin/docker -d")
$ ps aux | grep docker

# way II
$  sudo docker -d
2014/07/31 19:39:28 docker daemon: 1.1.2 d84a070; execdriver: native; graphdriver: 
[916c0d18] +job initserver()
[916c0d18.initserver()] Creating server
[916c0d18] +job init_networkdriver()
[916c0d18] +job serveapi(unix:///var/run/docker.sock)
2014/07/31 19:39:28 Listening for HTTP on unix (/var/run/docker.sock)
[916c0d18] -job init_networkdriver() = OK (0)
2014/07/31 19:39:28 WARNING: Your kernel does not support cgroup swap limit.
Error loading docker apparmor profile: exec: "/sbin/apparmor_parser": stat /sbin/apparmor_parser: no such file or directory ()
[916c0d18] -job initserver() = ERR (1)
2014/07/31 19:39:28 Error loading docker apparmor profile: exec: "/sbin/apparmor_parser": stat /sbin/apparmor_parser: no such file or directory ()

# the error message finger out the not-installed package 'apparmor'
$ sudo apt-get install apparmor

# check it is worked
$ sudo docker -d
2014/07/31 19:41:27 docker daemon: 1.1.2 d84a070; execdriver: native; graphdriver: 
[abe22d40] +job serveapi(unix:///var/run/docker.sock)
[abe22d40] +job initserver()
[abe22d40.initserver()] Creating server
[abe22d40] +job init_networkdriver()
2014/07/31 19:41:27 Listening for HTTP on unix (/var/run/docker.sock)
[abe22d40] -job init_networkdriver() = OK (0)
2014/07/31 19:41:27 WARNING: Your kernel does not support cgroup swap limit.
2014/07/31 19:41:27 Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
Loading containers: : done.
[abe22d40.initserver()] Creating pidfile
[abe22d40.initserver()] Setting up signal traps
[abe22d40] -job initserver() = OK (0)
[abe22d40] +job acceptconnections()
[abe22d40] -job acceptconnections() = OK (0)
# Ctrl + C to exit

$ sudo service docker start                # start up docker service (daemon)
docker start/running, process 13955

$ ps aux | grep docker
root     13955  1.2  0.1 331860  6376 ?  Ssl  02:05   0:00 /usr/bin/docker -d

$ sudo docker run -i -t ubuntu /bin/bash   # now try to run a image again, it should be ok
Unable to find image 'ubuntu' locally
Pulling repository ubuntu
ba5877dc9bec: Download complete 
511136ea3c5a: Download complete 
9bad880da3d2: Download complete 
25f11f5fb0cb: Download complete 
ebc34468f71d: Download complete 
2318d26665ef: Download complete 
還搞不清楚什麼是 docker 和他的原理嗎~
可以參考這幾篇說明喔...
5分鐘弄懂Docker!
docker 原理簡介

還有 slideshare 的投影片
Docker: an insider view



[ Reference ]
https://groups.google.com/forum/#!topic/docker-user/_BQ89Zi04-I
https://www.digitalocean.com/community/questions/start-docker-error-message

沒有留言:

張貼留言