原有的一种安装方式:html
curl -sSL https://get.docker.com/ | sudo sh如今貌似不提供了。。
因为官方文档变化频繁,若是安装方式与本文有差别以官方文档为准linux
查看内核版本,docker对内核版本有要求,ubuntu16.04确定符合,这一步能够略过docker
$ uname -r结果
4.4.0-47-generic
$ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates
$ sudo apt-key adv \ --keyserver hkp://ha.pool.sks-keyservers.net:80 \ --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
deb https://apt.dockerproject.org/repo ubuntu-xenial main
$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt-get update
$ apt-cache policy docker-engine
docker-engine: 已安装:(无) 候选: 1.12.3-0~xenial 版本列表: 1.12.3-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.2-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.1-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.12.0-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.2-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.1-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages 1.11.0-0~xenial 500 500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
$ sudo apt-get install docker-engine
$ sudo service docker start
$ sudo docker run hello-world
结果ubuntu
Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
若是出现网络问题没法下载,就先从网易蜂巢的镜像市场到hello-world运行bash
docker run hub.c.163.com/library/hello-world或者先pull后run
docker pull hub.c.163.com/library/hello-world:latest
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ docker run hello-world
若是运行出现网络
Cannot connect to the Docker daemon. Is the docker daemon running on this host?官方文档提示你设置环境变量,其实没什么用,从网上看到不少结果都是无心中忽然好了。。。
事实上是由于加入用户组这个东西必须注销或重启才能生效,你注销或者重启一下立刻就行了。
app
附:经常使用命令curl
docker version #查看版本 docker images #查看镜像列表 docker images -a #查看镜像列表 docker rmi -f [镜像id] #删除指定镜像