[iyunv@localhost nginx]# cat Dockerfile
# This is My first Dockerfile
# Version 1.0
# Author: Liuzhengwei
# Base images
FROM centos:base_newlatest
MAINTAINER mail:1135960569@qq.com
ADD nginx.repo /etc/yum.repos.d
RUN yum install nginx -y
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN useradd -s /sbin/nologin -M www
EXPOSE 80
CMD ["nginx"]
[iyunv@localhost nginx]# docker run -d -p 80 nginx-file:v1
6e43d596879c2b67fc74143957ef914ef842d78046812717919e576a629f694c
查看容器是否启动正常:
1
2
3
[iyunv@localhost nginx]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e43d596879c nginx-file:v1 "nginx" 7 minutes ago Up 7 minutes 0.0.0.0:32774->80/tcp sleepy_shannon