1

I just started playing around with Docker yesterday and am having issues between the build environment and the run environment. Build wise I have issues like...

RUN install.sh
/bin/sh: 1: install.sh: Permission denied
the command '/bin/sh -c install.sh' returned a non-zero code: 126

or ...

RUN . sourceme.env
/bin/sh: 1: .: sourceme.env: not found
The command '/bin/sh -c . sourceme.env' returned a non-zero code: 2

I build using 'sudo docker build -t joes' and I run using 'sudo docker run -it joes'

The frustrating thing is that after build failure I can run it, see that I am in the working directory I expected, and run the command that failed during building successfully. So why the discrepancy?

This is on a linux system and I'm using 'FROM ubuntu:18.04'

To bypass the RUN install.sh error I used

RUN /bin/sh install.sh

which converts to

/bin/sh -c /bin/sh install.sh
JoeManiaci
  • 435
  • 3
  • 15

2 Answers2

1

Post your entire Dockerfile. The problem is you haven't pointed to the correct location. When you copy it, copy it in and then supply it with the absolute path. e.g.

COPY install.sh /install.sh
CMD ./install.sh

EDIT: if your containers main job is to run the install.sh script then use it with CMD and not RUN. Use run to build env and evth else.

DUDANF
  • 2,618
  • 1
  • 12
  • 42
  • For this section it's literally just WORKDIR /some/dir => RUN svn co someurl => RUN . sourceme.env It fails, I then run the container(that was created up to that point by removing the broken line), I see that I am already in /some/dir and I can see the sourceme.env file. – JoeManiaci Nov 22 '19 at 18:02
  • Actually using /some/dir/sourceme.env works, but the paths inside break. What's the point of WORKDIR if the directory isn't used/visible? Also, my big problem is that /bin/sh and source do not mix. https://stackoverflow.com/questions/13702425/source-command-not-found-in-sh-shell/13702876 So how do I 'RUN' a command the way I would from a command line without invoking '/bin/sh' – JoeManiaci Nov 22 '19 at 18:23
  • @JoeManiaci Can you please edit your question and include your Dockerfile? That would help us reproduce your issue. – DUDANF Nov 25 '19 at 09:35
0

Using the RUN instruction in a Dockerfile with 'source' does not work Seems to be the bulk of my issue

That along with running multiple RUN commands instead of RUN ... && ... && ... etc

JoeManiaci
  • 435
  • 3
  • 15