【容器化】Docker部署

官网

official-website:https://www.docker.com/

中文教程:https://www.runoob.com/docker/docker-tutorial.html

简介

官方说明:Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

YUM方式部署

1. 准备

配置Docker-CE的YUM源

YUM默认源中的Docker是比较旧的,如果需要安装新版本的Docker,需要配置Docker-CE的YUM源。

1
2
curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast

结果截图:

查看可安装的Docker版本
1
yum list docker-ce --showduplicates

结果截图:

2. 安装部署

1
2
3
4
# 安装最新版本
# yum install -y docker-ce
# 安装指定指定版本
yum install -y docker-ce-3:19.03.15-3.el7.x86_64

结果截图:

3. 配置开机自启动及服务启动

1
2
systemctl enable docker
systemctl start docker

结果截图:

4. 配置私有仓库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mkdir -p /etc/docker
# 配置Docker私有仓库文件
cat << EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
"http://<IP>:<PORT>"
],
"insecure-registries": [
"<IP>:<PORT>"
]
}
EOF
# 重启Docker服务
systemctl daemon-reload
systemctl restart docker

5. 测试镜像拉取

1
docker pull busybox

结果截图:

(•̀ᴗ•́)و ̑̑

Share