我正在尝试将我的应用程序进行文档化,因为我一直在跟踪官方的openresty 码头文件。操作系统在我的系统是Ubuntu16.04 64位。
我已经用这个cmd拉出了那个图像。
docker pull openresty/openresty:1.11.2.3-xenial现在,我想使用这个图像,并想要制作简单的hello world应用程序。为此,我已经创建了我的工作目录,创建一个自定义dockerfile并使用它构建我的自定义映像。最后我运行了这张照片。下面是我的dockerfile内容。
FROM openresty/openresty:1.11.2.3-xenial
EXPOSE 8080
CMD nginx -p `pwd` -c nginx.confnginx.conf
worker_processes 1;
error_log stderr notice;
events {
worker_connections 1024;
}
http {
include /usr/local/openresty/nginx/conf/mime.types;
server {
listen 8888;
location / {
default_type text/html;
content_by_lua_file "app.lua";
}
}
}app.lua
ngx.say('Hello World!')
ngx.exit(200)构建图像
docker build -t user/openresty .
启动容器
docker run rahul/openresty当我尝试启动容器时,它会给出一个错误,比如nginx: nginx选项:"/bin/sh“
我不知道我走的方向是对还是错。
更新:
docker run -it -p 8888:80 -v /home/software/docker/openresty:/usr/local/openresty/nginx/html:ro openresty/openresty:1.11.2.3-xenial我刚刚使用了这个CLI,它开始显示我创建的index.html。同样,我试图使用下面的CLI链接我的自定义nginx.conf,但是它不起作用。
docker run -it -p 8888:8888 -v /home/software/docker/openresty:/usr/local/openresty/nginx/html:ro -v /home/software/docker/openresty/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf:ro openresty/openresty:1.11.2.3-xenialdocker run -it -p 8888:8888 -v $(pwd):/app openresty/openresty:1.11.2.3-异种-p /app -c nginx.conf
在下面的命令下,它开始工作,但是有人能解释一下吗?
docker run -it -p 8888:8888 -v $(pwd):/app openresty/openresty:1.11.2.3-xenial -p /app -c nginx.conf发布于 2019-10-02 21:38:58
您的端口设置错误,请看:
暴露8080 !=听8888;
https://stackoverflow.com/questions/44589081
复制相似问题