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
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.
Comments