Tôi đã sau docker-compose.yml
:Tại sao lệnh docker-compose này thất bại trong khi lệnh docker chạy thành công?
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
Edit: và Dockerfile sau:
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
Nếu tôi chạy docker-compose up
lệnh carton exec ...
thất bại:
$ 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
...
Tuy nhiên, nếu tôi chạy cùng một lệnh theo cách thủ công trên vùng chứa, lệnh này thành công:
$ 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/
Bất kỳ suy nghĩ nào về sự khác biệt giữa hai lệnh?
Để tham chiếu carton giống như Bundler cho Perl. Sử dụng carton exec
nên thiết lập môi trường Perl để các đường dẫn thư viện thích hợp được bao gồm chứa tất cả các ứng dụng phụ thuộc cụ thể - như làm việc với lệnh docker run
.
Chắc chắn, tôi cũng đã thêm Dockerfile. Vùng chứa web đã được xây dựng trước thời điểm này. –
Bạn có thể mở rộng trên ý nghĩa của định nghĩa khối lượng không? Các đồ tạo tác của thư viện được cài đặt dưới thư mục mã để điều này nghe giống như khu vực bên phải .. –
Được rồi, tôi đã nhận xét định nghĩa 'volume' và bây giờ nó bắt đầu. Tôi nghĩ rằng tôi sao chép từ một ví dụ Django hoặc Rails, tôi sẽ cần phải tìm kiếm những gì nó làm nhưng tôi là một bước xa hơn bây giờ! Làm thế nào tôi thực sự xem ứng dụng của tôi trong một trình duyệt sẽ là thử thách tiếp theo. Cảm ơn. –