构建具有“RUN apt-get update”的Dockerfile给了我“rootfs内的jail进程导致'perission被拒绝'”

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

我的docker主机是Ubuntu 19.04。我用snap安装了docker。我创建了一个Dockerfile,如下所示:

FROM ubuntu:18.04
USER root
RUN apt-get update
RUN apt-get -y install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
RUN wget http://nginx.org/download/nginx-1.15.12.tar.gz
RUN tar -xzvf nginx-1.15.12.tar.gz
RUN cd nginx-1.15.12
RUN ./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid --with-http_ssl_module
RUN make
RUN make install

我用这个命令运行它:

sudo码头工人建造。

我得到这个输出:

Sending build context to Docker daemon  3.584kB
Step 1/10 : FROM ubuntu:18.04
 ---> d131e0fa2585
Step 2/10 : USER root
 ---> Running in 7078180cc950
Removing intermediate container 7078180cc950
 ---> 2dcf8746bcf1
Step 3/10 : RUN apt-get update
 ---> Running in 5a691e679831
OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:109: jailing process inside rootfs caused \\\"permission denied\\\"\"": unknown

任何帮助将不胜感激!

docker ubuntu nginx dockerfile apt
1个回答
1
投票

您的问题有几个问题:

  1. 不要用sudo运行docker。如果不允许您自己的用户运行docker,则应将自己添加到docker组:sudo usermod -aG docker $(whoami)
  2. 你的一些RUN命令没有意义,或者至少没有你想要的意思 - 例如:RUN cd anything只会改变到特定RUN步骤内的目录。它不会传播到下一步。使用&&在一个RUN中链接几个命令或使用WORKDIR为后续步骤设置工作目录。
  3. 此外,你错过了wget

这是Dockerfile的工作版本:

FROM ubuntu:18.04

RUN apt-get update && apt-get -y install \
    build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev wget

RUN wget http://nginx.org/download/nginx-1.15.12.tar.gz

RUN tar -xzvf nginx-1.15.12.tar.gz

WORKDIR nginx-1.15.12

RUN ./configure \
    --sbin-path=/usr/bin/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --with-pcre \
    --pid-path=/var/run/nginx.pid \
    --with-http_ssl_module

RUN make && make install
© www.soinside.com 2019 - 2024. All rights reserved.