apt-get错误:版本' 5:19.03.4〜3-0〜ubuntu-bionic'用于' docker-ce'没有找到 [英] apt-get error: Version '5:19.03.4~3-0~ubuntu-bionic' for 'docker-ce' was not found

查看:116
本文介绍了apt-get错误:版本' 5:19.03.4〜3-0〜ubuntu-bionic'用于' docker-ce'没有找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档提供语法以安装 docker-ce 的特定版本:

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


在类似的行中, dockerfile 下面的代码使用上述语法:

  FROM jenkins/jenkins:ltsENV DEBIAN_FRONTEND =非交互式USER根ARG DOCKER_GID = 497#使用GID创建Docker组#如果Docker compose将DOCKER_GID设置为空白字符串,则将默认值设置为497RUN groupadd -g $ {DOCKER_GID:-497}泊坞窗#为docker,docker-compose&安装基本软件包Ansible#apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50&&\运行apt-get update -y&&\apt-get -y install bc \awlibffi-dev \musl-dev \apt-transport-https \卷曲python3 \python3-dev \python3-setuptools \gcc \制作 \libssl-dev \python3-pip#在构建时使用,但在运行时不使用ARG DOCKER_VERSION = 5:19.03.4〜3-0〜仿生#安装最新的Docker CE二进制文件并将用户`jenkins`添加到docker组运行apt-get update&&&\apt-get -y安装apt-transport-https \ca证书\卷曲gnupg-agent \软件属性-常见&&\curl -fsSL https://download.docker.com/linux/$(./etc/os-release; echo"$ ID")/gpg>/tmp/dkey;apt-key添加/tmp/dkey&&\添加apt存储库"deb [arch = amd64] https://download.docker.com/linux/$(./etc/os-release; echo" $ ID)\$(lsb_release -cs)\稳定"apt-get更新&&\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詹金斯ARG DOCKER_COMPOSE = 1.24.1#安装docker composeRUN 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运行pip3安装ansible boto3#更改为jenkins用户使用者詹金斯#添加jenkins插件COPY plugins.txt/usr/share/jenkins/plugins.txt运行/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 |在我的本地Docker主机中awk'NR == 1 {print $ 3}'


其中 docker-compose build 给出以下错误:

 正在读取状态信息...E:找不到'docker-ce'的版本'5:19.03.4〜3-0〜ubuntu-bionic'E:找不到'docker-ce-cli'的版本'5:19.03.4〜3-0〜ubuntu-bionic'错误:服务'jenkins'构建失败:命令'/bin/sh -c apt-get update&&apt-get -y install apt-transport-https ca证书curl gnupg-agent software-properties-common&&curl -fsSL https://download.docker.com/linux/$(./etc/os-release; echo"$ ID")/gpg>/tmp/dkey;apt-key添加/tmp/dkey&&add-apt-repository"deb [arch = amd64] https://download.docker.com/linux/$(./etc/os-release; echo" $ ID)$(lsb_release -cs)stable"&&apt-get更新&&apt-y -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} containered.io&&usermod -aG docker jenkins返回了非零代码: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.

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

 #apt-cache madison docker-cedocker-ce |5:19.03.4〜3-0〜debian-stretch |https://download.docker.com/linux/debian Stretch/stable amd64软件包docker-ce |5:19.03.3〜3-0〜debian-stretch |https://download.docker.com/linux/debian Stretch/stable amd64软件包docker-ce |5:19.03.2〜3-0〜debian-stretch |https://download.docker.com/linux/debian Stretch/stable amd64软件包docker-ce |5:19.03.1〜3-0〜debian-stretch |https://download.docker.com/linux/debian Stretch/stable amd64软件包docker-ce |5:19.03.0〜3-0〜debian-stretch |https://download.docker.com/linux/debian Stretch/stable amd64软件包 

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

 ⋮卸下中间容器baaeab34bb8c--->6d34bab07796步骤3/3:RUN否--->在8347f442dfaa中运行命令"/bin/sh -c false"返回了非零代码:1 

留下了 6d34bab07796 图片.您可以将其传递给 docker run 并调查命令失败的原因. 8347f442dfaa 容器也已保留,尽管已退出;您也可以使用各种 docker container 子命令进行调查.

Documentation provides syntax to install specific version of docker-ce:

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


On similar line, below dockerfile uses the above syntax:

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


fails at line below(on build):

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 && \

where default values are retrieved from command: apt-cache madison docker-ce | awk 'NR==1{print $3}' in my local docker host


where docker-compose build gives below error:

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 is able to download and install the latest version of ubuntu packages, but why download and install of specific version of ubuntu package fails?

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 && \

解决方案

You've selected Docker versions based on what's available on your build host, not what's available inside the container image you're building. The jenkins:lts image is based on Debian Stretch, not Ubuntu Bionic.

Dockerfiles are actually just running fairly ordinary Docker operations. So, for example, you can run docker run -ti -u root jenkins/jenkins:lts /bin/bash, run your RUN scripts by hand, and check the apt-cache output inside the container:

# 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

Also, a failed docker build should leave the partially-complete image around; so you can use that directly to investigate a failure. As an example with a trivially failing step 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

The 6d34bab07796 image is left around. You can pass that to docker run and investigate why the command failed. The 8347f442dfaa container is also left around, though exited; you can use the various docker container subcommands to investigate it as well.

这篇关于apt-get错误:版本&amp;#39; 5:19.03.4〜3-0〜ubuntu-bionic&#39;用于&amp;#39; docker-ce&amp;#39;没有找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆