通过构建镜像拒绝容器的Docker权限。

问题描述 投票:0回答:1

我试图从Dockerfile中构建镜像。为此,我使用了这个dockerhub镜像。https:/hub.docker.comropenshiftorigin-haproxy-router。

我的Dockerfile。

FROM openshift/origin-haproxy-router
RUN INSTALL_PKGS="haproxy18 rsyslog" && \
                  yum install -y $INSTALL_PKGS && \
                  yum clean all && \
                  rpm -V $INSTALL_PKGS && \
                  mkdir -p /var/lib/haproxy/router/{certs,cacerts,whitelists} && \
                  mkdir -p /var/lib/haproxy/{conf/.tmp,run,bin,log} && \
                  touch /var/lib/haproxy/conf/{{os_http_be,os_edge_reencrypt_be,os_tcp_be,os_sni_passthrough,os_route_http_redirect,cert_config,os_wildcard_domain}.map,haproxy.config} && \
                  setcap 'cap_net_bind_service=ep' /usr/sbin/haproxy && \
                  chown -R :0 /var/lib/haproxy && \
                  chmod -R g+w /var/lib/haproxy
COPY images/router/haproxy/* /var/lib/haproxy/
LABEL io.k8s.display-name="OpenShift HAProxy Router" \
  io.k8s.description="This component offers ingress to an OpenShift cluster via Ingress and Route rules." \
  io.openshift.tags="openshift,router,haproxy"
USER root
EXPOSE 80 443
WORKDIR /var/lib/haproxy/conf
ENV TEMPLATE_FILE=/var/lib/haproxy/conf/haproxy-config.template \
RELOAD_SCRIPT=/var/lib/haproxy/reload-haproxy
ENTRYPOINT ["/usr/bin/openshift-router"]

当我试着用dockerfile在文件夹里运行命令后,

sudo docker build -t os-router .

我得到了下一个结果。

 ovl: Error while doing RPMdb copy-up:
 [Errno 13] Permission denied: '/var/lib/rpm/Conflictname'
 You need to be root to perform this command.

我如何解决这个错误?

docker dockerfile docker-image
1个回答
0
投票

USER root 在您的docker文件中

© www.soinside.com 2019 - 2024. All rights reserved.