### **linux篇(debian系)**
**安装流程:**
1、进入命令行界面
2、切换至root用户界面
`$ sudo su root`
3、清除旧的仓库
~~~
$ apt-get purge lxc-docker*
$ apt-get purge docker.io*
~~~
4、添加一个新的gpg钥匙
`$ apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D`
5、根据debian的不同版本创建文件(下面以debian-jessie为例)
`$ echo 'deb https://apt.dockerproject.org/repo debian-jessie main' > /etc/aptsources.list.d/docker.list`
如果不知道自己的系统版本,输入以下命令:**uname -r**
~~~
# Debian Wheezy
deb https://apt.dockerproject.org/repo debian-wheezy main
# Debian Jessie
deb https://apt.dockerproject.org/repo debian-jessie main
# Debian Stretch/Sid
deb https://apt.dockerproject.org/repo debian-stretch main
# Ubuntu Precise
deb https://apt.dockerproject.org/repo ubuntu-precise main
# Ubuntu Trusty
deb https://apt.dockerproject.org/repo ubuntu-trusty main
# Ubuntu Vivid
deb https://apt.dockerproject.org/repo ubuntu-vivid main
# Ubuntu Wily
deb https://apt.dockerproject.org/repo ubuntu-wily main
~~~
6、更新apt包索引
`$ apt-get update`
7、验证apt是否从正确的仓库下载
`$ apt-cache policy docker-engine`
8、安装docker
`$ apt-get install docker-engine`
9、开启docker守护进程
`$ service docker start`
10、验证docker是否正常运行
`$ docker run hello-world`
**非root用户使用docker**
1、如果docker用户群不存在,增加docker用户群
`$ sudo groupadd docker`
2、将对应用户添加到docker用户群
`$ sudo gpasswd -a ${USER} docker`
3、重启docker守护进程
`$ sudo service docker restart`
**更新docker**
`$ apt-get upgrade docker-engine`
**卸载docker**
1、删除docker包
`$ sudo apt-get purge docker-engine`
2、删除docker包及不再需要的依赖包
`$ sudo apt-get autoremove --purge docker-engine`
3、删除docker镜像、容器、卷
`$ rm -rf /var/lib/docker`