docker - 易于获取错误 : Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found

标签 docker dockerfile ubuntu-18.04 apt-get docker-ce

Documentation 提供语法来安装特定版本的 docker-ce :

$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io


在类似的线路上,低于 dockerfile使用以上语法:

FROM jenkins/jenkins:lts

ENV DEBIAN_FRONTEND=noninteractive

USER root

ARG DOCKER_GID=497

# Create Docker Group with GID
# Set default value of 497 if DOCKER_GID set to blank string by Docker compose
RUN groupadd -g ${DOCKER_GID:-497} docker

# Install base packages for docker, docker-compose & ansible
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && \
RUN apt-get update -y && \
    apt-get -y install bc \
                    gawk \
                    libffi-dev \
                    musl-dev \
                    apt-transport-https \
                    curl \
                    python3 \
                    python3-dev \
                    python3-setuptools \
                    gcc \
                    make \
                    libssl-dev \
                    python3-pip 

# Used at build time but not runtime
ARG DOCKER_VERSION=5:19.03.4~3-0~ubuntu-bionic

# Install the latest Docker CE binaries and add user `jenkins` to the docker group
RUN apt-get update && \
    apt-get -y install apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common && \
    curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
    add-apt-repository \
      "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
      $(lsb_release -cs) \
      stable" && \
    apt-get update && \
    apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
        docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
        containerd.io && \
    usermod -aG docker jenkins

ARG DOCKER_COMPOSE=1.24.1

# Install docker compose
RUN curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE:-1.24.1}/docker-compose-$(uname -s)-$(uname -m)" \
    -o /usr/local/bin/docker-compose && \
    chmod +x /usr/local/bin/docker-compose

RUN pip3 install ansible boto3

# Change to jenkins user
USER jenkins

# Add jenkins plugin
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt

在下面一行失败(构建时):

apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
            docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
            containerd.io && \

默认值从命令中检索:apt-cache madison docker-ce | awk 'NR==1{print $3}'在我本地的 docker 主机中


哪里docker-compose build给出以下错误:

Reading state information...
E: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found
E: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce-cli' was not found
ERROR: Service 'jenkins' failed to build: The command '/bin/sh -c apt-get update &&     apt-get -y install apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common &&     curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey &&     add-apt-repository       "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")       $(lsb_release -cs)       stable" &&     apt-get update &&     apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic}         docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic}         containerd.io &&     usermod -aG docker jenkins' returned a non-zero code: 100

apt-get -y install docker-ce docker-ce-cli containerd.io能够下载并安装最新版本的ubuntu包,但为什么要下载并安装特定版本的 ubuntu包失败?

apt-get -y install docker-ce=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
                docker-ce-cli=${DOCKER_VERSION:-5:19.03.4~3-0~ubuntu-bionic} \
                containerd.io && \

最佳答案

您选择的 Docker 版本是基于构建主机上的可用版本,而不是您正在构建的容器镜像中的可用版本。 jenkins:lts 镜像基于 Debian Stretch,而不是 Ubuntu Bionic。

Dockerfiles 实际上只是在运行相当普通的 Docker 操作。因此,例如,您可以运行 docker run -ti -u root jenkins/jenkins:lts /bin/bash ,手动运行您的 RUN 脚本,并检查 apt-cache容器内的输出:

# apt-cache madison docker-ce
 docker-ce | 5:19.03.4~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
 docker-ce | 5:19.03.3~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
 docker-ce | 5:19.03.2~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
 docker-ce | 5:19.03.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
 docker-ce | 5:19.03.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages

此外,失败的 docker 构建应该留下部分完整的图像;因此您可以直接使用它来调查故障。作为一个简单失败步骤的例子 RUN false :

⋮
Removing intermediate container baaeab34bb8c
 ---> 6d34bab07796
Step 3/3 : RUN false
 ---> Running in 8347f442dfaa
The command '/bin/sh -c false' returned a non-zero code: 1

6d34bab07796图像留在周围。您可以将其传递给 docker run并调查命令失败的原因。 8347f442dfaa容器也留在周围,虽然退出了;你可以使用各种 docker container子命令也可以对其进行调查。

关于docker - 易于获取错误 : Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58821303/

相关文章:

visual-studio - 为什么在 Visual Studio 中结束调试后我的 docker 容器 ASP.NET 核心应用程序不可用

php - 如何从 ubuntu 中删除未使用的 php 版本?

static - docker 具有静态地址的多个容器

sql-server - 在 Dockerfile 中切换到 Root 用户

networking - Docker 桥接网络,容器之间的 HTTP 调用非常慢(在 docker 升级之后)

nginx - 如何 : stream with ffmpeg and nginx rtmp, Ubuntu

ubuntu - 找不到包 - 将 libav 添加到 PKG_CONFIG_PATH 环境变量

docker - 为什么我的卷是空的?

docker - 为什么我无法获得 docker build 创建的文件的尾部输出

linux - 在 Docker 中为 Linux 主机预留 CPU 和内存