ElasticBeanstalk上的Nginx Docker:没有这样的文件或目录

时间:2016-10-18 18:45:09

标签: java nginx docker elastic-beanstalk

我有一个nginx泊坞窗。这是Dockerfile:

FROM nginx

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY server.8079.conf /etc/nginx/conf.d

CMD nginx

当我通过docker run命令运行时,一切运行正常; /var/lib/nginx/var/log/nginx都具有正确的权限,日志文件在/var/log/nginx中创建,/var/lib/nginx/logs是指向/var/log/nginx的符号链接。但是,我无法将其部署到我的弹性beanstalk应用程序中。它由于以下错误而失败:

nginx: [alert] could not open error log file: open() "/var/lib/nginx/logs/error.log" failed (2: No such file or directory)
2016/10/20 17:19:26 [emerg] 5#0: open() "/var/log/nginx/error.log" failed (2: No such file or directory)

奇怪的是,当我进入Elastic Beanstalk服务器并使用docker run启动docker时,一切运行正常。这是docker运行文件:

{
  "containerDefinitions": [
    {
      "portMappings": [
        {
          "containerPort": 8079,
          "hostPort": 8079
        }
      ],
      "mountPoints": [
        {
          "containerPath": "/var/log",
          "sourceVolume": "awseb-logs-NginxSSLRedirect"
        }
      ],
      "memory": 128,
      "essential": true,
      "image": "id.dkr.ecr.us-west-2.amazonaws.com/nginx-redirect-ssl",
      "name": "nginxSSLRedirect"
    }
  ],
  "AWSEBDockerrunVersion": "2"
}

有没有人知道可能导致此问题的原因?

1 个答案:

答案 0 :(得分:0)

问题是日志文件夹绑定不正确。应该如下:

"mountPoints": [
  {
    "containerPath": "/var/log/nginx",
    "sourceVolume": "awseb-logs-NginxSSLRedirect"
  }
]