![[容器]docker创建镜像 [容器]docker创建镜像](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
手动创建:
docker run -d -p mynginx:v2 nginx
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install nginx -y
vi /etc/nginx/nginx.conf
daemon off;
docker ps -a
docker commit a823e15f958b oldboyedu/mynginx:v3
docker run -d -p : oldboyedu/mynginx:v3 nginx
用Dockerfile创建:
mkdir -p /opt/dockerfile/nginx
echo '<h1>test index</h1>' > index.html
[root@lanny nginx]# cat Dockerfile
FROM centos
MAINTAINER lanny.ma iher@foxmail.com
WORKDIR /etc/yum.repos.d/
ADD CentOS-Base.repo /etc/yum.repos.d/
RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
RUN yum install nginx -y
WORKDIR /etc/nginx
RUN echo 'daemon off;' >> /etc/nginx/nginx.conf
ADD index.html /usr/share/nginx/html
VOLUME ["/etc/nginx"]
VOLUME ["/usr/share/nginx/html"]
VOLUME ["/var/www"]
EXPOSE 80 443
CMD ["nginx"]
docker build -t oldboyedu/mynginx:v4 /opt/dockerfile/nginx/
docker run -d -p 80:80 oldboyedu/mynginx:v4
docker ps -a