I am getting this error while doing sudo docker build .
> (3:58:02 PM) njain: tep 28 : RUN python /tmp/setup.py install &&
> python /tmp/buzz/scripts/setuprabbit.py ---> Running in e7afcbda3c75
> Traceback (most recent call last): File "/tmp/setup.py", line 7, in
> <module>
> long_description=open('README.md', 'r').read(), IOError: [Errno 2] No such file or directory: 'README.md' 2014/10/15 15:40:14 The command
> [/bin/sh -c python /tmp/setup.py install && python
> /tmp/buzz/scripts/setuprabbit.py] returned a non-zero code
My Dockerfile looks like this:
ADD buzz /tmp/
# DOCKER-VERSION 0.3.4
#bunch of installs
RUN cd /tmp/
RUN python /tmp/setup.py install && python /tmp/buzz/scripts/setuprabbit.py
When I go in the container (interactive shell and CD to /tmp/) I am able to to do python setup.py install
without any issue.
Arthur's answer correctly identifies the cause of your problem, and provides a valid solution.
However, Docker's "Best Practices for Writing Dockerfiles" recommends against using the pattern he suggested (i.e. RUN cd /some/path && do-some-command
), and instead recommends using the WORKDIR
instruction (which is intended to address this exact use case).
WORKDIR
basically works exactly how you intended your cd
command to work: it changes working directory, with the new working directory being retained for later instructions in the Dockerfile.
In your case, the resulting Dockerfile would look like this:
ADD buzz /tmp/
# DOCKER-VERSION 0.3.4
#bunch of installs
WORKDIR /tmp/
RUN python /tmp/setup.py install && python /tmp/buzz/scripts/setuprabbit.py
each step in a docker file:
So your docker file says:
ADD buzz /tmp/ # change the container to have this new file
# DOCKER-VERSION 0.3.4
#bunch of installs
RUN cd /tmp/ # don't change the container at all and then save the results
RUN python /tmp/setup.py install && python /tmp/buzz/scripts/setuprabbit.py ## do the install
so the cd
command on the second to last line does nothing and does not affect lines after it. This is an unfortunate side effect of making docker files look too much like shell scripts which they are not. Instead put the cd
command on the same line that needs to use it so that it's effects will carry forward along that line though not to other RUN commands in the same Dockerfile
RUN cd /tmp/ && python /tmp/setup.py install && python /tmp/buzz/scripts/setuprabbit.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With