40

I'm new to docker so I might be doing this wrong, but I'm trying to install Tomcat6 through a Dockerfile which like this:

FROM rhel7:latest RUN cd /tmp RUN "wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz" RUN tar xzf apache-tomcat-6.0.44.tar.gz RUN mv apache-tomcat-6.0.44 /usr/local/tomcat6 RUN cd /usr/local/tomcat6 Run ./bin/start.sh 

Its failing on the 3rd line with the:

 RUN "wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz" 

When I run the docker build I get this: this

I'm using:

  • Oracle Virtual Box V4.3.28 r100309
  • Docker on RHEL7
2
  • I came across this post looking for a solution to a returned a non-zero code: 139 in a CentOS 7 server. I have solved my problem just uninstalling and reinstalling docker again. sudo yum remove docker.x86_64 docker-common.x86_64 docker-distribution.x86_64 docker-rhel-push-plugin.x86_64 sudo yum remove docker.x86_64 docker-common.x86_64 docker-distribution.x86_64 docker-rhel-push-plugin.x86_64 Commented Oct 26, 2017 at 21:14
  • @WellingtonSouza error 139 means you're compiling for wrong CPU architecture Commented Nov 6, 2018 at 12:00

5 Answers 5

24

Solution to the image with error is to add before the wget CMD RUN yum -y install wget

If you write it like this, it is the same result, just different execution:

 RUN wget http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz 

Don't use the quotes and comma in RUN command.

Sign up to request clarification or add additional context in comments.

4 Comments

It makes no difference to it, it still gives the same error
In that case, add the statement RUN yum -y install wget before the line that throws error.
Thanks, I'm after trying that, but it exits with code 1 now. This is what is displayed. i.imgur.com/wqmlenh.png I have a subscription with RedHat and I'm using it on the machine, do I have to do a subscription-manager login with Docker?
I've not used RHEL image since a while. But the message indicates that you need to register with Red Hat Subscription Manager. I'd suggest you to take Red Hat Support's help in this if you can.
19

Exit code 127 from shell commands means "command not found". So, in your case it seems the "wget" within quotes is not being found when Docker runs it.

In some cases, the command to install wget (or whatever command-line tool is missing) must first be run in the Dockerfile because some base Docker images will not have wget. You would add a line before the failing command that looks something like this:

RUN yum install -y wget 

Comments

4

Do not forget you can add all lib and package you need on the same line

RUN cd /tmp \ && apt-get update \ && apt-get install -y curl apt-utils wget unzip\ && rm -rf /var/lib/apt/lists/*

Comments

1

Note that the error message says that wget, is not found - note the trailing comma. You’ve mixed up the “shell form” and “exec form” of the RUN command.

The “exec form” of the RUN command uses a comma-separated list of double-quoted strings wrapped in square brackets. This is identical to the syntax for JSON arrays. This form looks like this:

RUN ["wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz"] 

In exec form, the array is used to directly execute the target program with the given arguments.

The shell form, on the other hand, consists simply of the command as if it were typed in at a shell prompt, and is distinguished from the exec form by the lack of square brackets. In shell form, the entire remainder of the line is passed to the shell as /bin/sh -c <command> (note that the command is passed as a single argument, even if it contains spaces). This therefore executes the remainder of the line as a shell command, allowing you to freely use shell variables, expansions, redirections, etc.

In your case, you’ve specified your RUN command as follows:

RUN "wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz" 

Because the command doesn’t start with a square bracket, this will be interpreted as a shell form command and executed through the shell. The shell will parse and discard the double quotes, resulting in the command

wget, http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz 

The trailing comma results in the command not being found.

To fix, either use standard exec form by adding square brackets, as above, or use standard shell form:

RUN wget 'http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz' 

(Note single quotes, which are generally good practice when passing arbitrary URLs through the shell).

Comments

0

Even though, error code was same, but my case was different. So, sharing my insight if someone face similar problem someday.

Exit code 127 means "command not found".

At my case I was using apt-get commands with alpine image, which should be apk add instead.

Sample Code:

# Install necessary extensions at alpine-distribution RUN apk add --no-cache --update \ curl \ openssl \ *other-dependencies* 

1 Comment

Note that Alpine also names many packages differently from Debian/Ubuntu, so you should take care to ensure you’re installing the right packages after changing the command.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.