安装docker.io包之前,需要先设置使用backports源
编辑/etc/apt/sources.list文件,加入下面这一句:
deb http://http.debian.net/debian jessie-backports main
然后执行:
$sudo apt-get update
$sudo apt-get install docker.io
如果出现:
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected program not found in PATH or not executable
解决ldconfig找不到的问题:
$apt-cache search ldconfig
得到:libc-bin - GNU C Library: Binaries
$sudo apt-get install libc-bin
然后我执行了一下:
$ldconfig
得到:bash: ldconfig: command not found
$/sbin/ldconfig
得到:
/sbin/ldconfig.real: Can't link /usr/lib/i386-linux-gnu/libfakeroot/libfakeroot-0.so to libfakeroot-tcp.so
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
#这个表示找到了
然后:
$su
$export PATH=/usr/loca/sbin:/usr/sbin:/sbin:$PATH
#这样就解决了
解决start-stop-daemon找不到的问题:
在https://stackoverflow.com/questions/25271936/expected-program-not-found-in-path-or-not-executable 看的做法
$cd /tmp
$wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
$tar zxf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
$cd apps/sys-utils/start-stop-daemon-IR1_9_18-2/
$gcc start-stop-daemon.c -o start-stop-daemon
$cp start-stop-daemon /usr/local/bin/start-stop-daemon
#但我不建议大家这么做,会出问题的,最好还是像解决ldconfig的问题那样去解决这个。
docker安上了,但是在执行以下命令的时候:
$sudo docker run hello-world
报错了:
FATA[0002] Error response from daemon: Cannot start container 22692eb807f4a73959e6cbfc6313bb4ea3670898b3e6f791cd87f4a4afe96057: [8] System error: exec format error
#是系统版本原因,官网要求是64位,我是Debian 8 i686的。
换成Ubuntu x86_64
按照官网来,一次成功。。
过程如下:
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce
$ apt-cache madison docker-ce
得到类似:
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
$ sudo apt-get install docker-ce=17.03.0~ce-0~ubuntu-xenial #版本按照上面来
$ sudo docker run hello-world #测试能不能运行,ok啦