基础镜像是按照上编博客-openResty入门-安装编 创建的以ubuntu 为原始镜像,执行 docker run -it ubuntu sh 之后执行一步一步安装,最后 docker commit 保存出来的镜像为基础镜像
➜ openresty git:(master) cat Dockerfile
FROM harbor.enncloud.cn/qinzhao-harbor/ubuntu-openresty:v1.0.0
ENV PATH /usr/local/openresty/nginx/sbin:$PATH
ADD nginx.conf /work/conf/
WORKDIR /work/
EXPOSE 8080
CMD /usr/local/openresty/nginx/sbin/nginx -g 'daemon off;' -c /work/conf/nginx.conf
nginx.conf的内容
➜ openresty git:(master) cat nginx.conf
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
执行docker build
docker build -t
reg.enncloud.cn/qinzhao-harbor/ubuntu-openresty:v1.0.14 -f Dockerfile
➜ openresty git:(master) sudo docker ps
Password:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81aa43d8ec48 reg.enncloud.cn/qinzhao-harbor/ubuntu-openresty:v1.0.14 "/bin/sh -c '/usr/..." 10 hours ago Up About an hour 0.0.0.0:9900->8080/tcp eager_euclid
访问localhost:9900