## 下麵命令都是以root用戶執行 ## 查看內核版本 uname -a # Debian 3.2.0-4 x86_64 ## 版本太低了
## 下麵命令都是以root用戶執行
## 查看內核版本
uname -a
# Debian 3.2.0-4 x86_64
## 版本太低了 < 3.8
## 參照 http://docs.docker.com/installation/debian/ 升級內核
deb http://http.debian.net/debian wheezy-backports main
apt-get update
apt-get install -t wheezy-backports linux-image-amd64
## 重啟系統
restart
## 安裝 docker 前,需要安裝 curl
apt-get install curl
## 安裝 docker
curl -sSL https://get.docker.com/ | sh
## 重啟 docker 服務.
service docker restart
## 運行 hello world
docker run hello-world
## 不出意外的話會出現
# FATA[0000] Get http:///var/run/docker.sock/v1.18/containers/json?all=1: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
## 這是docker服務沒有啟動
service docker status
# 會看到
# [FAIL] Docker is not running ... failed!
# 確實沒啟動
## 顯示啟動一下
docker -d
## 會看到
# INFO[0000] +job serveapi(unix:///var/run/docker.sock)
# INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
# INFO[0000] +job init_networkdriver()
# Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
# INFO[0000] -job init_networkdriver() = ERR (1)
# FATA[0000] Shutting down daemon due to errors: Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
## 因為阿裡雲把所有內網IP都占用了。所以要改下。
vi /etc/network/interfaces
## 把 "up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.170.191.247 dev eth0" 這一註釋掉(在這一行最前面加'#')
/etc/init.d/networking restart
service docker start
service docker status
## 能看到 docker is running.
docker run hello-world
## 能看到 hello-world 啟動了
# Hello from Docker.
# This message shows that your installation appears to be working correctly.
## 把非管理員用戶添加到docker組,方便使用
useradd -G docker <user_login>