Docker构建在入口点的COPY或ADD语句上失败,仅限Windows

时间:2017-02-23 21:19:10

标签: docker docker-compose file-permissions docker-windows

我正在为Docker容器创建一个入口点,然后尝试使用INFO 2017-02-23 20:53:51.352 [kg.apc.p] (): Starting measures: jmx:gc-time:url=localhost\:9080 ERROR 2017-02-23 20:53:51.445 [kg.apc.p] (): Failed to get MX Bean data provider java.lang.IllegalArgumentException: Can't define JMX type at kg.apc.perfmon.metrics.jmx.AbstractJMXDataProvider.getProvider(AbstractJMXDataProvider.java:48) at kg.apc.perfmon.metrics.JMXMetric.<init>(JMXMetric.java:42) at kg.apc.perfmon.metrics.AbstractPerfMonMetric.createMetric(AbstractPerfMonMetric.java:65) at kg.apc.perfmon.PerfMonMetricGetter.setUpMetrics(PerfMonMetricGetter.java:138) at kg.apc.perfmon.PerfMonMetricGetter.processCommand(PerfMonMetricGetter.java:63) at kg.apc.perfmon.PerfMonMetricGetter.processNextCommand(PerfMonMetricGetter.java:101) at kg.apc.perfmon.PerfMonWorker.read(PerfMonWorker.java:210) at kg.apc.perfmon.PerfMonWorker.processCommands(PerfMonWorker.java:97) at kg.apc.perfmon.AgentTool.processParams(AgentTool.java:72) at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:63) at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at kg.apc.cmd.UniversalRunner.main(UniversalRunner.java:175) ERROR 2017-02-23 20:53:51.446 [kg.apc.p] (): Invalid metric specified: jmx java.lang.RuntimeException: Failed to get MX Bean data provider at kg.apc.perfmon.metrics.JMXMetric.<init>(JMXMetric.java:45) at kg.apc.perfmon.metrics.AbstractPerfMonMetric.createMetric(AbstractPerfMonMetric.java:65) at kg.apc.perfmon.PerfMonMetricGetter.setUpMetrics(PerfMonMetricGetter.java:138) at kg.apc.perfmon.PerfMonMetricGetter.processCommand(PerfMonMetricGetter.java:63) at kg.apc.perfmon.PerfMonMetricGetter.processNextCommand(PerfMonMetricGetter.java:101) at kg.apc.perfmon.PerfMonWorker.read(PerfMonWorker.java:210) at kg.apc.perfmon.PerfMonWorker.processCommands(PerfMonWorker.java:97) at kg.apc.perfmon.AgentTool.processParams(AgentTool.java:72) at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:63) at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at kg.apc.cmd.UniversalRunner.main(UniversalRunner.java:175) Caused by: java.lang.IllegalArgumentException: Can't define JMX type at kg.apc.perfmon.metrics.jmx.AbstractJMXDataProvider.getProvider(AbstractJMXDataProvider.java:48) at kg.apc.perfmon.metrics.JMXMetric.<init>(JMXMetric.java:42) ... 14 more 文件运行它。 这在Ubuntu和OS X中运行良好,但我在Windows中收到权限错误(没有太多其他信息)

这是Dockerfile:

docker-compose.yml

这是docker-compose.yml条目:

FROM node:6.9

MAINTAINER Some Dude <dude@dude.com>

WORKDIR /opt

# Install Compass
RUN DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
RUN apt-get -y update
RUN apt-get -y install gcc rubygems ruby-dev
RUN gem update --system
RUN gem install compass

# Install Compass Extensions
RUN gem install compass-blend-modes compass-import-once

# Install glup globally
RUN npm install -g gulp

# Copy the setup file
COPY setup/gulp/docker-gulp-setup.sh /usr/local/bin/docker-gulp-setup.sh
RUN chmod +x /usr/local/bin/docker-gulp-setup.sh

CMD ['gulp']

以下是在Windows上运行build命令时的输出:

version: '2'

services:

        mycontainer-for-gulp:
                build:
                        context: .
                        dockerfile: Dockerfile.gulp
                volumes:
                        - ./:/opt:Z
                command: /usr/local/bin/docker-gulp-setup.sh

请注意,λ docker-compose build mycontainer-for-gulp Building mycontainer-for-gulp Traceback (most recent call last): File "<string>", line 3, in <module> File "compose\cli\main.py", line 65, in main File "compose\cli\main.py", line 117, in perform_command File "compose\cli\main.py", line 223, in build File "compose\project.py", line 300, in build File "compose\service.py", line 742, in build File "site-packages\docker\api\build.py", line 55, in build File "site-packages\docker\utils\utils.py", line 95, in tar File "tarfile.py", line 2023, in add File "tarfile.py", line 2052, in addfile File "tarfile.py", line 278, in copyfileobj IOError: [Errno 13] Permission denied docker-compose returned -1 命令是生成错误的,因为我们尝试单独注释掉COPY语句。

当我运行原始docker构建查询时:

RUN chmod

然后我尝试对当前目录进行tar操作时得到一堆错误输出。基本上每个文件添加都失败了。完整输出在这里:

https://gist.github.com/danieltalsky/4cb6bddb6534c46b051230bc45578072

2 个答案:

答案 0 :(得分:0)

当应用程序仍在IDE中运行时,我尝试构建Docker映像时遇到了同样的问题。

请确保在构建映像之前关闭应用程序

答案 1 :(得分:0)

在 PyCharm 中工作时,我已将我的子文件夹设置为“源根”(右键单击文件夹名称 > 将目录标记为 > 源根)。当我将子文件夹作为源根删除时,此错误消失了