0

I am trying to build a custom Docker image using a Dockerfile. The base image I am using is this one:

l3iggs/archlinux

My Dockerfile is like this:

FROM l3iggs/archlinux:latest

COPY source /srv/visitor

WORKDIR /srv/visitor

RUN pacman -Syyu --needed --noconfirm &&
        pacman -S --needed --noconfirm cronie nodejs phantomjs &&
        printf "1.2.3.4 www.hahaha.org \n" >> /etc/hosts &&
        printf "*/2 * * * *       node /srv/visitor/visitor.js \n" >> cronJobs &&
        printf "*/5 * * * *       killall -older-than 5m phantomjs \n" >> cronJobs &&
        printf "0 0 * * * rm /srv/visitor/visitor-info.log \n" >> cronJobs &&
        crontab cronJobs &&
        rm cronJobs &&
        npm install

EXPOSE 80

CMD ["/bin/sh", "-c"]

Now, when it gets to the "RUN" part, where it is supposed to update, it hangs and outputs this error message:

Step 3 : RUN pacman -Syyu --needed --noconfirm &&
 ---> Running in ae19ff7ca233
/bin/sh: -c: line 1: syntax error: unexpected end of file
INFO[0013] The command [/bin/sh -c pacman -Syyu --needed --noconfirm &&] returned a non-zero code: 1

Any ideas?

UPDATE 1:

Now, I suspect my issue has more to do with the "RUN" command, than with the "pacman -Syyu" being executed inside the container. This should really not be braking things, but it clearly is.

dlyk1988
  • 1,674
  • 4
  • 24
  • 36

1 Answers1

1

You are missing \ for building your command across multiple lines. The run command should look more like:

RUN pacman -Syyu --needed --noconfirm && \
        pacman -S --needed --noconfirm cronie nodejs phantomjs && \
        printf "1.2.3.4 www.hahaha.org \n" >> /etc/hosts && \
        printf "*/2 * * * *       node /srv/visitor/visitor.js \n" >> cronJobs && \
        printf "*/5 * * * *       killall -older-than 5m phantomjs \n" >> cronJobs && \
        printf "0 0 * * * rm /srv/visitor/visitor-info.log \n" >> cronJobs && \
        crontab cronJobs && \
        rm cronJobs && \
        npm install

Though, a couple things to note:

Andy Shinn
  • 4,211
  • 8
  • 40
  • 55