文章目录
- 1.docker 安装
- 2.docker环境实现Nginx
1.docker 安装
1.使用环境为红帽8.1,添加源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2.安装
yum install docker-ce docker-ce-cli containerd.io
显示出错
Docker CE Stable - x86_64 70 kB/s | 15 kB 00:00
error: problem with installed package podman-3.0.1-6.module_el8.4.0+781+acf4c33b.x86_64
- package podman-3.0.1-6.module_el8.4.0+781+acf4c33b.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
- package podman-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
- package containerd.io-1.4.9-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
- package containerd.io-1.4.9-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
- package containerd.io-1.4.9-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
- package containerd.io-1.4.9-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
- cannot install the best candidate for the job
- package runc-1.0.0-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
- package runc-1.0.0-65.rc10.module_el8.4.0+819+4afbd1d6.x86_64 is filtered out by modular filtering
- package runc-1.0.0-70.rc92.module_el8.4.0+786+4668b267.x86_64 is filtered out by modular filtering
- package runc-1.0.0-71.rc92.module_el8.4.0+833+9763146c.x86_64 is filtered out by modular filtering
解决方案
yum erase podman buildah
再次安装
安装成功
2.docker环境实现Nginx
1.启动docker
systemctl start docker
2.查看转发
cat /proc/sys/net/ipv4/ip_forward
如果显示不符为1则需要手动设为1
echo 1 > /proc/sys/net/ipv4/ip_forward
3.查看docker版本
docker version
4.修改docker默认配置文件
vim /etc/docker/daemon.json
添加的内容
{
"registry-mirrors": ["https://eu5rxjvf.mirror.aliyuncs.com"]
}
systemctl daemon-reload #启动配置
systemctl restart docker #重启docker服务
5.查看配置结果
docker init
6.搜索Nginx源
docker search nginx
7.导入Nginx环境
docker pull nginx #默认最高版本
8.查看当前docker环境
docker images
9.启动容器
docker run -d --name nginx01 -p 80:80 nginx
534af161b4995c62fdd9f4d57fb4bb787a68cf040035ac96304473703230073d #容器id自己记住
10.查看容器
docker ps
11.访问测试
curl 127.0.0.1:80
12.进入容器修改配置
docker exec -it 534 /bin/bash
#534是之前容器id的前三位,不用写全