我正在尝试封装我的vue-js应用程序:下面是我的docker文件:
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" ]当我试图使用详细标志-v运行对接时,我会得到以下错误:
$ 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".没有-v标志,我得到以下信息:
$ 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然后如果我试图进入容器:
$ 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"我也收到同样的错误,但是导航到带有端口的ip地址,找不到页面。
发布于 2018-08-05 04:48:47
docker container run命令的格式是:
Usage: docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]因此,在执行docker run -it vue-js-app -v时,-v将作为命令传递给容器,替换Dockerfile (CMD [ "http-server", "dist" ])中指定的命令。这会导致消息“$PATH中找不到可执行文件”,因为容器中没有名为-v的命令。
如果试图将-v传递给http-server,则必须重复Dockerfile中的现有命令。
docker container run -it vue-js-app http-server dist -v这将在容器中运行http-server dist -v。
至于在容器中执行shell,在$PATH中找不到bash,因为在映像中没有安装bash。node:9.11.1-alpine基于Alpine,它使用ash作为默认的shell。因此,您应该使用ash在正在运行的容器中执行shell进程。
docker container exec -it 0778c0e3ae05 ash发布于 2018-08-05 05:07:05
你写:“得到同样的错误,但导航到ip地址的端口,我得到的页面找不到”。
这是因为您没有映射端口。你揭露它,但你也应该映射它。在运行命令的引用中的“头:公开(传入端口):https://docs.docker.com/v1.13/engine/reference/run/”下的docker中查找信息
-P :将所有公开的端口发布到主机接口。-p=[]:将容器᾿的端口或一系列端口发布到主机格式: ip: hostPort :containerPort \ip::hostPort和containerPort都可以指定为一系列端口。当指定两个范围时,该范围内的容器端口数必须与该范围内的主机端口数目相匹配,例如:-p 1234-1236:1234-1236/tcp仅为hostPort指定范围时,containerPort不能是范围。在这种情况下,容器端口是在指定的hostPort范围内发布的。(例如,
-p 1234-1236:1234/tcp) (使用“停靠端口”查看实际映射)
https://stackoverflow.com/questions/51691341
复制相似问题