红联Linux门户
Linux帮助

ubuntu 16.04 docker安装事项

发布时间:2016-06-18 09:49:11来源:linux网站作者:l6807718

1.安装认证文件

$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
$ sudo vim /etc/apt/sources.list.d/docker.list
添加 deb https://apt.dockerproject.org/repo ubuntu-xenial main


2.安装Docker-engine

$ sudo apt-get install docker-engine


3.测试并停止docker

$ sudo service docker stop


4.修改/etc/default/docker文件

DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock --mtu 1454 --storage-driver=devicemapper --storage-opt dm.basesize=1G --insecure-registry 10.109.252.221:5000 --insecure-registry 192.168.1.208:5000"


5.修改/lib/systemd/system/docker.service文件,否则配置文件无法生效

添加EnvironmentFile=-/etc/default/docker
修改ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS


6.改aufs文件系统为devicemapper

$ sudo rm -rf /var/lib/docker
$ mkdir -p /var/lib/docker/devicemapper/devicemapper
$ sudo dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/data bs=1G count=0 seek=100
$ systemctl daemon-reload
$ systemctl start docker


7.最重要的一点是要安装dmsetup,否则会报错Can’t set task name /dev/mapper/docker-252:1-541528-pool,或者无响应

$ sudo apt install dmsetup


本文永久更新地址:http://www.linuxdiyf.com/linux/21613.html