ONBUILD选项出现错误(Windows中的Docker工具箱)
问题描述:
我在Docker上的Docker有问题(通过Docker Toolbox)。可能有人可以帮忙。ONBUILD选项出现错误(Windows中的Docker工具箱)
我Dockerfile没有ONBUILD:
FROM node:5.9.1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "start" ]
EXPOSE 3000
工作正常(搬运工建立-t测试并启动它:搬运工运行 - 它--rm --name testrun测试) 但如果我改变Dockerfile到ONBUILD选项:
FROM node:5.9.1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD COPY package.json /usr/src/app/
ONBUILD RUN npm install
ONBUILD COPY . /usr/src/app
CMD [ "npm", "start" ]
EXPOSE 3000
我得到一个错误:
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm ERR! Linux 4.1.19-boot2docker
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v5.9.1
npm ERR! npm v3.7.3
npm ERR! path /usr/src/app/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.js
on'
npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.js
on'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /usr/src/app/npm-debug.log
我做错了什么? (即时通讯新手在Docker :))。也许我错了使用ONBUILD?但是就像没有明确的事情一样,没有。
答
的
ONBUILD
指令增加了图像在以后的时间,当图像被用作基地另一个构建要执行的触发指令。
既然你不使用其他图像开始“FROM test
”,这些指令是永远不会被执行,这意味着test
图像不包括什么这些命令应该做的事情。
答
除非您在问题中遗漏了一些细节,否则您没有正确使用ONBUILD
。
ONBUILD
选项是将命令排队以在后续构建中运行。上面指定的命令不会被执行,除非您通过将其包含在另一个Dockerfile中的FROM
引用中来包装图像。
有关此主题的更多信息,请参阅Dockerfile reference。