将Perl Docker容器部署到Elastic Beanstalk

时间:2015-04-14 20:48:11

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

我正在构建一个Docker容器,它从bitbucket中提取perl / mojolicious repo,但我遇到了问题。我有这样的Dockerfile:

# DOCKER-VERSION 0.3.4
FROM        perl:latest
MAINTAINER  My Name myname@name.com

# Update aptitude with new repo
RUN apt-get update

# Install software 
RUN apt-get install -y git
# Make ssh dir
RUN mkdir /root/.ssh/

# Copy over private key, and set permissions
ADD repo-key /root/.ssh/id_rsa

# Create known_hosts
RUN touch /root/.ssh/known_hosts
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

RUN curl -L http://cpanmin.us | perl - App::cpanminus
RUN cpanm Mojolicious

RUN cachebuster=b953b35 git clone -b branch git@bitbucket.org:org/project.git

EXPOSE 8080

WORKDIR project
CMD hypnotoad script/project

而且,在本地,docker build -t name/project .它建立得很好,并说“成功建造。”

我用repo-key文件将其压缩并将其提供给Elastic Beanstalk,我点击了上传和部署(我成功部署了2048游戏样本,并尝试复制它)。

这回来Dockerrun.aws.json: No such file or directory。我认为这很奇怪,因为文档说Dockerfile或Dockerrun.aws.json可以独立用于不同的需求。但无论如何,我给了它一个简短的,希望无关紧要的Dockerrun.aws.json,就像这样:

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

它仍然失败,现在日志会显示[CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/04run.sh] command failed with error code 1:并进一步Docker container quit unexpectedly after launch

有人可以帮我解决这些问题吗?

1 个答案:

答案 0 :(得分:2)

我明白了。问题是默认情况下hypnotoad在后​​台运行,这会使容器立即死亡。通过添加-f标志,它在前台运行,容器仍然存在。我还将CMD切换为ENTRYPOINT

#... same as above except for last line

WORKDIR project
ENTRYPOINT [ "hypnotoad", "-f", "./script/project" ]

你仍然必须向EB提供Dockerfile和Dockerrun.aws.json,但没有明显的原因,但即便如此,它也能正常运行。