简体   繁体   中英

Docker : starting container process caused “exec: \”-n\“: executable file not found in $PATH”: unknown

While launching a command on my docker image (run), I get the following error:

C:\Program Files\Docker\Docker\resources\bin\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-n\": executable file not found in $PATH": unknown.

The image is an image for Jmeter, that I have created myself:

FROM        hauptmedia/java:oracle-java8

MAINTAINER  maisie

ENV         JMETER_VERSION  5.2.1
ENV         JMETER_HOME /opt/jmeter
ENV         JMETER_DOWNLOAD_URL https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz

RUN         apt-get clean
RUN         apt-get update
RUN         apt-get -y install ca-certificates              
RUN         mkdir -p ${JMETER_HOME}                         
RUN         cd ${JMETER_HOME}                           
RUN         wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.2.1.tgz
RUN         tar -xvzf apache-jmeter-5.2.1.tgz   
RUN         rm apache-jmeter-5.2.1.tgz          

The command that I am launching is:

#!/bin/bash

export volume_path=$(pwd)

export jmeter_path="/opt/apache-jmeter-5.2.1/bin"

docker run --volume ${volume_path}:${jmeter_path} my/jmeter -n -t ${jmeter_path}/TEST.jmx -l ${jmeter_path}/res.jtl

I really can't find any answer to my problem...

Thank you in advance for any help.

The general form of the docker run command is

docker run [docker options] <image name> [command]

So you are running an image named amos/jmeter , and the command you are having it run is -n -t... . You're getting the error you are because you've only given a list of options and not an actual command.

The first part of this is to include the actual command in your docker run line:

docker run --rm amos/jmeter \
  jmeter -n ...

There's also going to be a problem with how you install the software in the Dockerfile. (You do not need a docker run --volume to supply software that's already in the image.) Each RUN command starts in a new shell in a new environment (in a new container even), so saying e.g. RUN cd... in its own line doesn't do anything. You need to use Dockerfile directives like WORKDIR and ENV to change the environment. The jmeter command isn't in a standard binary directory so you'll also have a little trouble running it. I might change:

# ...

# Run all APT commands in a single command
# (Layer caching can break an install if the list of packages changes)
RUN apt-get clean \
 && apt-get update \
 && apt-get -y install ca-certificates

# Download and unpack the JMeter tar file
# This is all in a single RUN command, so
# (1) the `cd` at the effect has (temporary) effect, and
# (2) the tar file isn't committed to an image before you `rm` it
RUN cd /opt \
 && wget ${JMETER_DOWNLOAD_URL} \
 && tar xzf apache-jmeter-${JMETER_VERSION}.tgz \
 && rm apache-jmeter-${JMETER_VERSION}.tgz

# Create a symlink to the jmeter process in a normal bin directory
RUN ln -s /opt/apache-jmeter-${JMETER_VERSION}/bin/jmeter /usr/local/bin

# Indicate the default command to run
CMD jmeter

Finally, there will be questions around where to store data files. It's better to store data outside the application directory; in a Docker context it's common enough to use short (if non-standard) directory paths like /data . Remember that any file path in a docker run command refers to a path in the container, but you need a docker run -v bind-mount option (your original --volume is equivalent) to make it visible on the host. That would give you a final command like:

docker run -v "$PWD:/data" atos/jmeter \
    jmeter -n -t /data/TEST.jmx -l /data/res.jtl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM