为什么我在docker / aws eb上收到权限被拒绝错误?

时间:2015-05-25 05:13:01

标签: amazon-web-services docker elastic-beanstalk

我不知道为什么,但我似乎无法弄清楚为什么会这样。我可以在本地构建和运行docker镜像。

近期活动:

2015-05-25 12:57:07 UTC+1000    ERROR   Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.
2015-05-25 12:57:07 UTC+1000    INFO    New application version was deployed to running EC2 instances.
2015-05-25 12:57:04 UTC+1000    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2015-05-25 12:57:04 UTC+1000    ERROR   [Instance: i-4775ec9b] Command failed on instance. Return code: 1 Output: (TRUNCATED)... run Docker container: vel="fatal" msg="Error response from daemon: Cannot start container 02c057b331bf3a3d912bf064f1dca3e00c95746b5748c3c4a28a5c6b452ff335: [8] System error: exec: \"bin/app\": permission denied" . Check snapshot logs for details. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2015-05-25 12:57:03 UTC+1000    ERROR   Failed to run Docker container: vel="fatal" msg="Error response from daemon: Cannot start container 02c057b331bf3a3d912bf064f1dca3e00c95746b5748c3c4a28a5c6b452ff335: [8] System error: exec: \"bin/app\": permission denied" . Check snapshot logs for details.

Dockerfile:

FROM java:8u45-jre
MAINTAINER Terence Munro <terry@zenkey.com.au>
ADD ["opt", "/opt"]
WORKDIR /opt/docker
RUN ["chown", "-R", "daemon:daemon", "."]
USER daemon
ENTRYPOINT ["bin/app"]
EXPOSE 9000

Dockerrun.aws.json:

{
  "AWSEBDockerrunVersion": "1",
  "Ports": [
    {
      "ContainerPort": "9000"
    }
  ],
  "Volumes": []
}

附加日志作为附件:https://forums.aws.amazon.com/thread.jspa?threadID=181270

非常感谢任何帮助。

@nick-humrich尝试eb local run工作的建议。所以使用eb deploy最终工作。

我以前通过网络界面上传。

最初使用eb deploy给了我一个ERROR: TypeError :: data must be a byte string,但我发现这个issue已通过卸载pyopenssl解决了。

所以我不知道为什么网页界面给我许可否认可能与zip文件有关?

但无论如何我现在可以部署了谢谢你。

1 个答案:

答案 0 :(得分:3)

我在Elastic Beanstalk上运行Docker时遇到了类似的问题。当我将Dockerfile中的CMD指向shell脚本(/path/to/my_script.sh)时,EB部署将失败 /path/to/my_script.sh: Permission denied.

显然,即使我在Docker构建期间运行RUN chmod +x /path/to/my_script.sh,但在运行映像时,权限也已更改。最后,为了使它成功,我决定:

CMD ["/bin/bash","-c","chmod +x /path/to/my_script.sh && /path/to/my_script.sh"]