perl – 为什么这个docker-compose命令在docker run命令成功时失败?

前端之家收集整理的这篇文章主要介绍了perl – 为什么这个docker-compose命令在docker run命令成功时失败?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有以下docker-compose.yml:

db:
    image: postgres
search:
    image: elasticsearch
web:
    build: .
    working_dir: /code
    environment:
        CATALYST_CONFIG_LOCAL_SUFFIX: development
    volumes:
        - .:/code
    ports:
        - "8000:8000"
    links:
        - db
        - search
    command: carton exec plackup -E development bicycleevents_web.psgi -p 8000

编辑:和以下Dockerfile:

FROM ubuntu:latest

RUN apt-get update
RUN apt-get install -y --force-yes build-essential curl libssl-dev postgresql-client libpq-dev perl-doc
RUN apt-get clean

RUN curl -L https://cpanmin.us | perl - --sudo App::cpanminus
RUN cpanm Carton
RUN mkdir /code
WORKDIR /code
ADD . /code/
RUN rm -rf /code/local/
RUN carton install

如果我运行docker-compose up carton exec …命令失败:

$docker-compose up
...
Starting bicycleeventsweb_web_1
web_1    | Error while loading /code/bicycleevents_web.psgi: Can't locate Moose.pm in @INC (you may need to install the Moose module) (@INC contains: /code/lib /code/local/lib/perl5 /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /code/lib/BicycleEvents/Web.pm line 2.
web_1    | BEGIN Failed--compilation aborted at /code/lib/BicycleEvents/Web.pm line 2.
web_1    | Compilation Failed in require at /code/bicycleevents_web.psgi line 6.
web_1    | BEGIN Failed--compilation aborted at /code/bicycleevents_web.psgi line 6.
bicycleeventsweb_web_1 exited with code 2
...

但是,如果我在容器上手动运行相同的命令,它会成功:

$docker run -i -t -e "CATALYST_CONFIG_LOCAL_SUFFIX=development" bicycleeventsweb_web carton exec plackup -E development bicycleevents_web.psgi -p 8000
...
HTTP::Server::PSGI: Accepting connections at http://0:8000/

有关这两个命令之间有什么不同的想法吗?

作为参考,@L_301_0@就像Bundler for Perl.使用carton exec应该设置Perl环境,以便包含包含所有特定于应用程序的依赖项的相应库路径 – 与docker run命令一起使用.

最佳答案
我们能看到正在构建的Dockerfile吗? (我在评论中缺乏声誉.编辑:谢谢!)

(编辑:)

我注意到的一个区别是你正在安装. to / code in docker-compose file,但是你不能手动运行命令.我并不熟悉Carton,但是当你在Dockerfile中执行carton安装时,如果它在/ code中创建了工件,你可能会因为docker-compose卷定义而丢失它们.

原文链接:https://www.f2er.com/docker/436077.html

猜你在找的Docker相关文章