Docker 18.03 Centos7.6 安装 内网

首先访问https://download.docker.com/linux/centos/7/x86_64/stable/Packages/获取对应版本的rpm包

docker包

docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm

依赖包

rpm -ivh container-selinux-2.99-1.el7_6.noarch.rpm

rpm -ivh pigz-2.3.3-1.el7.centos.x86_64.rpm

挂载光盘镜像安装依赖包

yum install policycoreutils-python libseccomp -y

rpm -ivh container-selinux-2.99-1.el7_6.noarch.rpm

rpm -ivh pigz-2.3.3-1.el7.centos.x86_64.rpm

rpm -ivh docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm

配置国内阿里云的加速镜像

登陆阿里云,找到控制板,找到容器镜像服务,找到镜像加速器

编辑/etc/docker/daemon.json配置文件;如没有该文件,则创建,加入如下代码

{

"registry-mirrors": ["https://x5aj5ctb.mirror.aliyuncs.com"]

}

#https://x5aj5ctb.mirror.aliyuncs.com为加速地址,每个人的不一样。

重载服务,重启docker,加入开机启动

systemctl daemon-reload

systemctl restart docker

systemctl enable docker

搜索镜像

docker search nginx

拉取镜像

docker pull nginx

运行镜像

docker run --name testnginx -p 8081:80 -d nginx

   

--name testnginx:指定运行之后的实例名称为testnginx

-p 8080:80 :指定将主机的8081端口映射到docker内的80端口,

-d :指定实例在后台一直运行

nginx :指定实例所使用的镜像名称

测试nginx页面是否正常

使用浏览器访问主机的IP地址下的8081端口,如果开启防火墙主机调试防火墙

http://192.168.197.30:8081/

运行已经配置好的实例

docker start testnginx

testnginx为实例名称

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

猜你喜欢

转载自www.cnblogs.com/withfeel/p/11201265.html