user2574872 user2574872 - 1 year ago 50
Python Question

"python install" does not work from Dockerfile but i can go in the container and do the same..any pointers?

I am getting this error while doing "sudo docker build ."

> (3:58:02 PM) njain: tep 28 : RUN python /tmp/ install &&
> python /tmp/buzz/scripts/ ---> Running in e7afcbda3c75
> Traceback (most recent call last): File "/tmp/", line 7, in
> <module>
> long_description=open('', 'r').read(), IOError: [Errno 2] No such file or directory: '' 2014/10/15 15:40:14 The command
> [/bin/sh -c python /tmp/ install && python
> /tmp/buzz/scripts/] returned a non-zero code

my Dockerfile looks like this :-

ADD buzz /tmp/
#bunch of installs
RUN cd /tmp/
RUN python /tmp/ install && python /tmp/buzz/scripts/

when i go in the container (interactive shell and CD to /tmp/ i am able to to do python install without any issue)

Answer Source

each step in a docker file:

  • creates a container
  • changes it in some way
  • commits the result (usually) to create a new image
  • removes the container.
  • use the new image in the next step

So your docker file says:

ADD buzz /tmp/            # change the container to have this new file
#bunch of installs
RUN cd /tmp/              # don't change the container at all and then save the results
RUN  python /tmp/ install &&  python /tmp/buzz/scripts/  ## 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/ install &&  python /tmp/buzz/scripts/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download