How to create a docker image with passenger?
It works good, gems are well installed, but when I call the app, I have this error :
Message from application: libruby.so.2.1: cannot open shared object file: No such file or directory – /home/app/webapp/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.18.3/pg_ext.so (LoadError)
And when I’m connecting to the image, the file /home/app/webapp/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.18.3/pg_ext.so really exists.
So I don’t understand what happened.
My docker file :
FROM phusion/passenger-ruby21:0.9.12 MAINTAINER Eric L'Hostis "firstname.lastname@example.org" # Set correct environment variables. ENV HOME /root # Use baseimage-docker's init system. CMD ["/sbin/my_init"] # Conf Nginx / Passenger RUN rm -f /etc/service/nginx/down RUN rm /etc/nginx/sites-enabled/default ADD nginx.conf /etc/nginx/sites-enabled/webapp.conf # Prepare folders RUN mkdir /home/app/webapp WORKDIR /tmp ADD Gemfile /tmp/ ADD Gemfile.lock /tmp/ RUN bundle install # Add the rails app ADD . /home/app/webapp
And to create/run the image.
docker build -t myimage . docker run -d -p 80:80 myimage
I have already trying to install these libs : libpq-dev, nodejs, build-essential, postgresql
without success 🙁
One Solution collect form web for “How to create a docker image with passenger?”
My assumption is that you’re using postgres as database and you are missing
libpq-dev in your image.
I don’t use passenger when deploying rails apps with docker, but I think you should check if the lib is installed.
You could just try to add:
RUN apt-get install -y libpq-dev
DOCKERFILE to install the lib.
or even better:
RUN apt-get update && \ apt-get install -y libpq-dev --no-install-recommends && \ rm -rf /var/lib/apt/lists/* && \ apt-get clean
If you wan’t your image to be as small as possible.
In my opinion the base image you’re using contains huge overhead. When working with docker my images are usually less than 400 MB. The base image you use is ~960 MB. You should check whether you could use
:latest as it’s way smaller (~211 MB).