6
我有以下docker-compose.yml
:爲什麼docker-compose命令在docker run命令執行成功時失敗?
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/
對這兩個命令之間有什麼不同的想法?
僅供參考carton就像Bundler for Perl。使用carton exec
應該設置Perl環境,以便包含適當的庫路徑,其中包含所有應用程序特定的依賴關係 - 與docker run
命令配合使用。
當然,我也添加了Dockerfile。這個Web容器已經被建立了。 –
您可以擴展您定義的卷的含義嗎?庫文物安裝在代碼目錄下,所以這聽起來像是正確的區域。 –
好的,我已經註釋了'volume'定義,它現在開始。我想我從Django或Rails的例子中複製出來,我需要查看它的功能,但我現在更進一步了!我如何在瀏覽器中實際查看我的應用程序將是下一個挑戰。謝謝。 –