apt-get install -y openjdk-8-jdk 失败

Apt-get install -y openjdk-8-jdk fails

DockerFile 上通过 apt 安装 openjdk-8-jdkLinux 节点 运行 Jenkins 我收到以下消息:

The command apt-get update && apt-get install -y openjdk-8-jdk returned a non-zero code: 100.

完整日志:

Step 5/7 : RUN apt-get update && apt-get install -y openjdk-8-jdk ---> Running in ...

...

Err:4 http://deb.debian.org/debian stretch Release Could not open file /var/lib/apt/lists/partial/deb.debian.org_debian_dists_stretch_Release - open (28: No space left on device)

Err:5 http://deb.debian.org/debian stretch-updates Release Could not open file /var/lib/apt/lists/partial/deb.debian.org_debian_dists_stretch-updates_Release - open (28: No space left on device)

Err:6 http://security.debian.org/debian-security stretch/updates Release Could not open file /var/lib/apt/lists/partial/security.debian.org_debian-security_dists_stretch_updates_Release - open (28: No space left on device) Reading package lists...

我该怎么做才能解决这个问题?

您的设备上没有剩余 space。清除 space 并重试

我发现这个问题的最佳解决方案是在每次构建后清除 space。使用 docker system prune 手动清除设备上的 space 并不是完美的解决方案,因为在一些构建之后你必须继续清理它。

pipeline {
    stages {
        stage ('start') {
            ...
        }
     }

     post {
        always {
            sh "docker system prune -f"
        }
     }
}