我一直在尝试设置将托管Nginx服务器的本地docker容器.首先,这是我的Dockerfile:
# Set Nginx base image
FROM Nginx
# File Author / Maintainer
MAINTAINER myuser "myemail@mydomain.com"
# Copy custom configuration file from the current directory
COPY Nginx.conf /etc/Nginx/Nginx.conf
我确实使用docker build命令构建了这个文件,当我列出图像时,我可以在列表中看到该图像.
现在,我尝试运行此新创建的映像,导致出现错误:
my-MacBook-Pro:Nginx-docker me$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myrepo Nginx-latest 0d73419e8da9 12 minutes ago 182.8 MB
hello-world latest c54a2cc56cbb 13 days ago 1.848 kB
Nginx latest 0d409d33b27e 6 weeks ago 182.8 MB
my-MacBook-Pro:Nginx-docker me$docker run -it myrepo:Nginx-latest
2016/07/15 07:07:35 [emerg] 1#1: open() "/etc/Nginx/logs/access.log" Failed (2: No such file or directory)
Nginx: [emerg] open() "/etc/Nginx/logs/access.log" Failed (2: No such file or directory)
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/Nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
root /Users/me/Projects/SandBox/my-app;
#charset koi8-r;
access_log logs/host.access.log main;
#
# Wide-open CORS config for Nginx
#
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
# /api will server your proxied API that is running on same machine different port
# or another machine. So you can protect your API endpoint not get hit by public directly
location /api {
proxy_pass http://localhost:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Origin $http_origin;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# deny access to .htaccess files,if Apache's document root
# concurs with Nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
include servers/*;
}
2016/07/15 07:07:35 [emerg] 1#1: open() "/etc/Nginx/logs/access.log" Failed (2: No such file or directory)
Nginx: [emerg] open() "/etc/Nginx/logs/access.log" Failed (2: No such file or directory)
我应该怎么做才能解决这个问题?还有那条路应该在哪里?我想它是在Docker公开的底层OS路径上吗?
最佳答案
原文链接:/nginx/532466.html