Docker 构建退出,退出代码为 : 1

标签 docker ubuntu curl apt

这个问题在这里已经有了答案:





The command '/bin/sh -c apt-get install dnsutils' returned a non-zero code: 1

(2 个回答)


8 个月前关闭。




目的是在一个容器中拥有一个 Docker CLI,这样我就可以在这个容器中与主机守护进程通信。因此我想在运行命令中连接套接字。
我有一个以下开始的 Dockerfile。当我省略 Curl 和 Docker CLI 部分时,构建的其余部分工作正常。

FROM ubuntu:20.04 as build
#might be even more slim, yet has not yet been tested: debian-stable-slim
RUN  apt-get update \
  && apt-get install -y wget
RUN apt-get update && \
      apt-get -y install sudo

RUN apt-get update && \
    apt-get install curl

## Install Docker CLI:
ENV DOCKERVERSION=20.10.9
RUN sudo curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
  && tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
                 -C /usr/local/bin docker/docker \
  && rm docker-${DOCKERVERSION}.tgz
这是带有错误消息的构建日志:
[+] Building 3.2s (8/9)
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 567B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                          1.2s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                                                                                            0.0s
 => [1/5] FROM docker.io/library/ubuntu:20.04@sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322                                                                    0.0s
 => CACHED [2/5] RUN  apt-get update   && apt-get install -y wget                                                                                                                        0.0s
 => CACHED [3/5] RUN apt-get update &&       apt-get -y install sudo                                                                                                                     0.0s
 => ERROR [4/5] RUN apt-get update &&  apt-get install curl                                                                                                                              1.9s
------
 > [4/5] RUN apt-get update &&  apt-get install curl:
#8 0.395 Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
#8 0.415 Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
#8 0.441 Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
#8 0.517 Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
#8 0.623 Reading package lists...
#8 1.142 Reading package lists...
#8 1.631 Building dependency tree...
#8 1.733 Reading state information...
#8 1.836 The following additional packages will be installed:
#8 1.836   krb5-locales libasn1-8-heimdal libbrotli1 libcurl4 libgssapi-krb5-2
#8 1.836   libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
#8 1.836   libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
#8 1.836   libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
#8 1.836   libnghttp2-14 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules
#8 1.836   libsasl2-modules-db libsqlite3-0 libssh-4 libwind0-heimdal
#8 1.837 Suggested packages:
#8 1.837   krb5-doc krb5-user libsasl2-modules-gssapi-mit
#8 1.837   | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp
#8 1.837   libsasl2-modules-sql
#8 1.866 The following NEW packages will be installed:
#8 1.867   curl krb5-locales libasn1-8-heimdal libbrotli1 libcurl4 libgssapi-krb5-2
#8 1.867   libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
#8 1.867   libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
#8 1.867   libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
#8 1.868   libnghttp2-14 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules
#8 1.869   libsasl2-modules-db libsqlite3-0 libssh-4 libwind0-heimdal
#8 1.874 0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
#8 1.874 Need to get 3197 kB of archives.
#8 1.874 After this operation, 10.5 MB of additional disk space will be used.
#8 1.874 Do you want to continue? [Y/n] Abort.
------
executor failed running [/bin/sh -c apt-get update &&   apt-get install curl]: exit code: 1
不可能选择 Y/n,因为它会立即退出。有没有人知道如何解决这个问题?
我在 Windows 上使用 Docker,版本 20.10.8
非常感谢!

最佳答案

apt get install将等待用户输入。你错过了 -y标志以允许它在没有人为干预的情况下继续:

RUN apt-get update && \
    apt-get install -y curl

关于Docker 构建退出,退出代码为 : 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69752207/

相关文章:

Bash 解析 docker status 检查本地镜像是否是最新的

selenium - Docker Container 无法访问 localhost 端口 4444。为什么?

docker - 在不启动设置为自动重启的容器的情况下启动Docker守护程序

shell - 请求端口时启动服务

ubuntu - 使用 ffserver 开始流式传输简单的 mp4

docker - 如何在docker 0.9.x中设置hwaddr

linux - 如何递归地 curl 所有文件

php - 验证码 GET/POST

cURL 中 Json 未定义

php - API https ://www. google.com/analytics/feeds/data 不工作