Docker Community Forums

Share and learn in the Docker community.

Issues with bash script and docker container


(Jhechtf) #1

I’m having the strangest thing with a custom docker image I’m trying to build for my job.

Long and short of it is that it’s going to be used for a ruby on rails app that we’re serving up via puma, using nginx as a reverse proxy. The eventual plan is to have the nginx / rails be separate containers, but for right now I’m just trying to get them working using a single image. The issue is that the image dies immediately upon creation using with the following error:

standard_init_linux.go:190: exec user process caused “exec format error”

I looked around and found a couple of places that seem to indicate that the main error would be that I am creating the file on windows, which uses CRLF, which can cause errors with the shebang up top. I tried multiple times converting from CRLF to LF in VSCode, but found it didn’t change anything. I did find that when I ran file that it was saying that it was solely an ASCII file, and not an executable.

To get around all of this I created the file in the linux container itself and used docker cp to extract the file from the container. If I go into the container using docker run -it rails-nginx bash and run file I get Bourne-Again shell script, ASCII text executable

But even after rebuilding the image the container still immediately dies.

Ideas, anyone?


FROM ruby
RUN apt-get update -y && apt-get install -y curl nginx && gem install bundler rails && \
    curl -sSL | bash - &&\
    curl -sS | apt-key add - &&\
    echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
    apt-get update -y && apt-get -y install nodejs yarn
VOLUME /var/www/rails-app
WORKDIR /var/www/rails-app
ADD /var/www/rails-app
RUN chmod +x
ADD default.conf /etc/nginx/sites-available/default
CMD ["./"]

Note: I’ve also tried to change it to the full path, CMD ["/var/www/rails-app/"] with no change in outputp

bundle install
service nginx start
rails server

I’m not going to add default.conf as this doesn’t seem to pertain to it – nginx starts just fine and if I mount the volume and start the rails server manually it works without issue.