Centos不再支持服务了?新yum仓库+docker配置教程

yum配置

当你输入yum repolist时报错并提示库为0:

说明你的centos yum不行了

直接复制下面的代码到面板就可以

1
2
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)

选择一个你喜欢的源:

然后等待安装ok就行

docker换源教程

安装docker:

1
yum install -y yum-utils
1
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

修改源:

1
vi /etc/docker/daemon.json

按键盘上的 i 键,之后把下面的代码贴进去

1
2
3
4
5
6
7
8
9
10
{
"registry-mirrors" :
[
"https://docker.m.daocloud.io",
"https://noohub.ru",
"https://huecker.io",
"https://dockerhub.timeweb.cloud",
"https://docker.rainbond.cc"
]
}

esc键,退出编辑模式。

:wq 保存。

重启

docker systemctl restart docker

Docker 常见命令:

删除镜像:

1
docker rmi [name/id]

拉取镜像:

1
docker pull -d [name] 

启动容器:

1
docker start [name]

删除容器:

1
docker rm -f [name]

一键拉取启动容器:

1
docker run -d --name [name] -e [环境] -p [宿主机端口映射到容器的端口]

进入容器内部:

1
docker exec -it [name] bash

黑马商城部署注意事项

1
docker run -d --name hmall --network hmall -p 8080:8080 hmall

前端nginx:

1
2
3
4
5
6
7
8
docker run -d \
--name nginx \
-p 18080:18080 \
-p 18081:18081 \
-v /root/nginx/html:/usr/share/nginx/html \
-v /root/nginx/nginx.conf:/etc/nginx/nginx.conf \
--network hmall \
nginx