Why does the docker-compose command fail when I run the docker launch command?

I have the following 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 

Edit: and the following Docker file:

 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 

If I run docker-compose up , the carton exec ... command will fail:

 $ 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 ... 

However, if I run the same command manually in the container, it succeeds:

 $ 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/ 

Any thoughts on what is different between the two teams?

For reference, carton is similar to Bundler for Perl. Using carton exec should configure the Perl environment so that the appropriate library paths are included that contain all the application-dependent dependencies โ€” how the docker run command works.

+6
source share
1 answer

Can we see the built dockerfile, please? (I don't have enough reputation to ask in the comments. Edit: Thank you!)

(Edit :)

One point that I notice is that you install . in /code to the docker build file, but you do not execute the command manually. I am not familiar with Carton specifically, but if it creates artifacts inside /code when you do carton install in the Docker file, you might lose them as a result of defining your docker-compose volumes .

+2
source

All Articles