我正在使用ubuntu,nginx组件进行POC,我已经在下面提到了Dockerfile
FROM ubuntu:14.04
MAINTAINER Paresh Bhavsar "bhavsar.er@gmail.com"
ENV REFRESHED AT "04-06-2015"
RUN apt-get update
RUN apt-get -y -q install nginx
RUN mkdir -p /var/www/html
ADD nginx/global.conf /etc/nginx/conf.d/
ADD nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
nginx.conf文件---
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
events { }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
}
global.conf文件
server {
listen 0.0.0.0:80;
}
root /var/www/html/website;
index index.html index.htm;
docker容器正在运行,显示如下所述。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e32a617896a pbhavsar211/nginx:latest "nginx" 15 minutes ago Up 15 minutes 0.0.0.0:49163->80/tcp website
我无法显示localhost:49153页面,尝试使用ip地址但没有运气。
我在这里遗漏了什么。提前谢谢。
答案 0 :(得分:0)
我认为root和index规则必须位于global.conf文件中的server标记内,如下所示:
server {
listen 0.0.0.0:80;
root /var/www/html/website;
index index.html index.htm;
}