Ubuntu安装Docker ce流程
实际操作中发现,Docker对32位系统支持并不好,对于Win10自带的ubuntu貌似也会出一点问题。尝试之后本人决定使用Ubuntu 16.04。
1. 准备工作
卸载旧版本:
$ sudo apt-get remove docker
docker-engine
docker.io
Ubuntu 14.04 可选内核模块(16.04版本无需本步):
$ sudo apt-get update
$ sudo apt-get install
linux-image-extra-$(uname -r)
linux-image-extra-virtual
2. 使用 APT安装
添加https传输支持:
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
向 source.list 中添加 Docker 软件源:
sudo add-apt-repository \
“deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable”
3. 安装 Docker CE
$ sudo apt-get update
$ sudo apt-get install docker-ce
4. 启动docker-ce
$ sudo systemctl enable docker
$ sudo systemctl start docker
如果是14.04,使用以下命令启动:
$ sudo service docker start
5. 建立 docker 用户组
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
6. 测试 Docker 是否安装正确
$ sudo docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:
- The Docker client contacted the Docker daemon.
- The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)- The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.- 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 bashShare images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
如果出现以上界面,说明安装成功。
6. 镜像加速
- ubuntu 14.04:
编辑 /etc/default/docker 文件,在其中的 DOCKER_OPTS 中配置加速器地址,然后重新启动:DOCKER_OPTS=”–registry-mirror=https://registry.docker-cn.com"
$ sudo service docker restart - ubuntu 16.04:
对于使用 systemd 的系统,请在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件):{
“registry-mirrors”: ["https://registry.docker-cn.com"
]
}
之后重新启动服务:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker