0

So I have the Dockerfile

FROM rust:1.19.0
RUN set -x \
    && apt-get update \
    && apt-get install git
RUN git clone https://gitlab.localhost.com/iron-site.git \
    && cd ./iron-site \
    && cargo build --all \
    && cp ./target/debug/*-site /usr/local/bin \
    && cd .. \
    && rm -rf iron-site


From nginx
COPY --from=0 /usr/local/bin/*-site /usr/local/bin/
ENV DATABASE_INI_FILE /srv/test.ini
COPY nginx.conf /etc/nginx/nginx.conf
COPY test.ini /srv/
COPY start.sh /usr/local/bin/
RUN chmod 770 /usr/local/bin/start.sh
RUN echo ls -la /usr/local/bin/
CMD /usr/local/bin/start.sh

So in essence the first stage builds some rust binaries when executed will generate unix sockets. The second stage just runs those binaries with a nginx instance that proxies the http requests to the correct unix socket. When I build everything works no errors are produced. However, when I run sudo docker run site-image where site-image is the tag for the image I get nothing. No output or errors and no container so I am confused as to how I could debug the issue further and or resolve the issue.

Lastly, my OS is fedora 27 and the docker version is 17.12.0-ce

The start.sh script is as follows:

#!/bin/bash

rm -f /run/nginx.pid
nginx -t
site_names=( $(find /usr/local/bin -name '*-site' | cut -d '/' -f5) )
for site in ${site_names[@]}; do
  /usr/local/bin/$site -p /run/nginx/$site.sock -x 1024
done
nginx -g daemon off
  • The first step is probably to start a shell instead of using the `start.sh` script (`docker run site-image bash`), and then manually run your `start.sh` script with `bash -x /usr/local/bin/start.sh`. That will trace the execution of the script. Does it do what you expect? – larsks Jan 05 '18 at 16:24
  • @larsks I tried running `sudo docker run site-image bash` and this just produces a new terminal line, that is, no interesting output and no new shell to interact with. So I thought it might be because I still had the CMD line in there so I removed that as well, but I still get no output and it just jumps to a new terminal line. –  Jan 05 '18 at 16:39
  • Sorry, when starting a shell you need to add `-it` (`docker run -it ...`). – larsks Jan 05 '18 at 16:43
  • @larsks The script executes but fails, I discovered that there may be some other files that I might need to copy over from the previous stage. I'll try to figure out what I need and get back to you. –  Jan 05 '18 at 17:12
  • @larsks The solution for https://stackoverflow.com/a/40488199/5960886 worked for me, but thank you for the help. –  Jan 06 '18 at 23:19
  • Possible duplicate of [Trying to build a docker container, start.sh not found](https://stackoverflow.com/questions/40487747/trying-to-build-a-docker-container-start-sh-not-found) –  Jan 06 '18 at 23:20

0 Answers0