基于上次制作的centos-systemctl:1.0镜像,在其上安装nginx rpm,并构建nginx镜像。
1.制作nginx Dockerfile,并保存
命令:
vim Dockerfile
FROM centos-systemctl:1.0
MAINTAINER ztj
COPY nginx.repo /etc/yum.repos.d/
COPY epel.repo /etc/yum.repos.d/
COPY epel-testing.repo /etc/yum.repos.d/
RUN yum install nginx net-tools -y
EXPOSE 80
2.基于Dockerfile创建镜像
命令:
docker build -f Dockerfile -t centos-nginx:1.0 .
[root@centos79 ~]# docker build -f Dockerfile -t centos-nginx:1.0 .
[+] Building 0.2s (10/10) FINISHED docker:default
=> [internal] load build definition from Dockerfile
本文介绍了如何基于centos-systemctl:1.0镜像安装Nginx并构建新的Docker镜像。通过编写Dockerfile,使用`docker build`创建镜像,然后使用`docker run`启动容器。最后,通过SSH验证Nginx服务并在浏览器中检查其运行状态。
订阅专栏 解锁全文
479

被折叠的 条评论
为什么被折叠?



