Getting error executable file not found in $PATH when trying verbose run docker container or when docker exec

Ciasto piekarz

I am trying to containerize my vue-js app: and below is my docker file:

FROM node:9.11.1-alpine

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory
WORKDIR /app

# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# install project dependencies
RUN npm install

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# build app for production with minification
RUN npm run build

EXPOSE 8080
CMD [ "http-server", "dist" ]

when I try to run docker with verbose flag -v I get this error:

$ docker run -it vue-js-app -v
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"-v\": executable file not found in $PATH".

and without -v flag I get the below:

$ docker run -it vue-js-app
Starting up http-server, serving dist
Available on:
  http://127.0.0.1:8080
  http://172.17.0.3:8080
Hit CTRL-C to stop the server

and then if I try to enter the container:

$ docker exec -it 0778c0e3ae05  bash
oci runtime error: exec failed: container_linux.go:265: starting container process caused "exec: \"bash\": executable file not found in $PATH"

I get same error , but navigating to ip address with port i get page not found

King Chung Huang

The format of the docker container run command is:

Usage:  docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]

So, when you execute docker run -it vue-js-app -v, the -v is being passed to the container as the command, replacing the command specified in the Dockerfile (CMD [ "http-server", "dist" ]). This results in the message “executable file not found in $PATH” because there is not a command named -v in the container.

If you are trying to pass -v to http-server, you have to repeat the existing command in the Dockerfile.

docker container run -it vue-js-app http-server dist -v

This will run http-server dist -v in the container.

As for executing a shell in the container, bash is not found in $PATH because bash is not installed in the image. node:9.11.1-alpine is based on Alpine Linux, which uses ash as the default shell. So, you should use ash to execute a shell process in your running container.

docker container exec -it 0778c0e3ae05 ash

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

"sqlplus": executable file not found in $PATH" when running a command with docker exec

Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown

exec: "gcc": executable file not found in %PATH% when trying go build

Docker's "executable file not found in $PATH: unknown" trying to run "cd"

Trying to create docker container function app, when i do docker run getting the error "Storage not defined"

Docker Error: OCI runtime create failed: runc create failed: unable to start container process: exec: ".": executable file not found in $PATH: unknown

Docker image error when run it : file not found

Docker Go image: starting container process caused: exec: "app": executable file not found in $PATH: unknown

Docker Base Simple image : Cannot start container XXX: exec: "cat": executable file not found in $PATH

Docker container build faild: "exec: \"flask\": executable file not found in $PATH": unknown

Golang docker multi-stage build failing to run: exec: "go": executable file not found in $PATH

docker-exec failed: "cd": executable file not found in $PATH

docker local registry "exec: \"htpasswd\": executable file not found in $PATH"

exec: "com.docker.cli": executable file not found in $PATH

exec: "docker-runc": executable file not found in $PATH: unknown

docker: executable file not found in $PATH

Docker Build and Docker run `no such file or directory` when file exists as executable

Error when trying to install puppeteer in Docker container

Error when trying to expose a docker container in minikube

docker compose oci runtime error, executable file not found in $PATH

Docker executable not found in PATH when using AWS batch/ECS

strptime throws error when run in docker container

docker-compose run and exec: No container found

Docker Node.js container error unexpected token '.' when trying to run the container

Docker --mount throws: executable file not found in $PATH"

Docker, \"ping\": executable file not found in $PATH": unknown

Docker elasticsearch 1.7 executable file not found in $PATH"

Docker compose executable file not found in $PATH": unknown

System error: exec format error when I start a docker container