构建具有“ RUN apt-get update”的Dockerfile,使我“在rootfs内导致“拒绝渗透”的崩溃过程”

时间:2019-04-30 13:01:43

标签: docker ubuntu nginx dockerfile apt

我的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 docker build。

我得到以下输出:

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

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分: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