Ubuntu
前提条件
Docker
安装需要Ubuntu
系统内核版本高于3.10, 这里我们通过uname -r
查看你当前的内核版本
uname -r
# 4.4.0-62-generic
这里显示的4.40版本,我们可以安装
安装
使用脚本进行安装
获取Docker的安装包
wget -qO https://get.docker.com/ | sh
将用户加入到docker组, 默认情况下,docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker 用户组。
sudo usermod -aG docker ligaotao
切换到ligaotao
用户测试一下Docke是否安装成功
sudo su - ligaotao
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
Status: Downloaded newer image for hello-world:latest
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.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output yo
u 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 ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
看到以上信息,就说明你已经安装成功了
配置镜像加速器
这里我们使用阿里云的镜像加速器,编辑/etc/docker/daemon.json
文件, 如果不存在就新建该文件
{
"registry-mirrors": [
"https://ae70tmgb.mirror.aliyuncs.com"
]
}
重启docker服务
sudo systemctl daemon-reload
sudo systemctl restart docker
3. 检查配置是否生效
docker info
如果输出内容中有
Registry Mirrors:
https://ae70tmgb.mirror.aliyuncs.com
则成功