大网数据广告活动
服务器运维问答

Docker COPY and effect on permissions?

· 52CE 我爱测

I'm modifying an existing docker image which was originally as follows: FROM puppet/puppetserver-standalone:2.7.2 ENV PUPPETDB_TERMINUS_VERSION="4.3.0" RUN apt-get update && \ apt-get install --no-install-recommends -y puppetdb-t…

问题原文

原帖链接 · Philip Kirkbride · CC BY-SA 3.0

I'm modifying an existing docker image which was originally as follows:

FROM puppet/puppetserver-standalone:2.7.2

ENV PUPPETDB_TERMINUS_VERSION="4.3.0"

RUN apt-get update && \
    apt-get install --no-install-recommends -y puppetdb-termini="$PUPPETDB_TERMINUS_VERSION"-1puppetlabs1 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN puppet config set storeconfigs_backend puppetdb --section main && \
    puppet config set storeconfigs true --section main && \
    puppet config set reports puppetdb --section main

COPY puppetdb.conf /etc/puppetlabs/puppet/

COPY Dockerfile /

There is already a command copying to /etc/puppetlabs/puppet/ I'm now an additional script to the same folder by adding a second COPY as follows:

COPY node.sh /etc/puppetlabs/puppet/

This change compiles but when I use the image in a docker-compose project everything breaks. It seems to be related to a permission issue:

puppet | Caused by: org.jruby.exceptions.RaiseException: (RuntimeError) Got 8 failure(s) while initializing: File[/opt/puppetlabs/server/data/puppetserver/state]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/state; File[/opt/puppetlabs/server/data/puppetserver/lib]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/lib; File[/opt/puppetlabs/server/data/puppetserver/preview]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/preview; File[/opt/puppetlabs/server/data/puppetserver/bucket]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/bucket; File[/opt/puppetlabs/server/data/puppetserver/yaml]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/yaml; File[/opt/puppetlabs/server/data/puppetserver/server_data]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/server_data; File[/opt/puppetlabs/server/data/puppetserver/reports]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/reports; File[/opt/puppetlabs/server/data/puppetserver/facts.d]: change from absent to directory failed: Could not set 'directory' on ensure: Permission denied - /opt/puppetlabs/server/data/puppetserver/facts.d

I'm really puzzled because there was already a .conf file being copied to the same folder before I added my modification. Does anyone have an idea on how this change may have affected permissions?

已采纳解答

原帖链接 · Philip Kirkbride · CC BY-SA 3.0

According to the page on DockerHub the image code should be identical to the github code.

I found that importing the image directly in a second docker image instead of modifying the original seemed to work:

Dockerfile:

FROM puppet/puppetserver

COPY node.sh /etc/puppetlabs/puppet/

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。