Docker Community Forums

Share and learn in the Docker community.

E: Version was not found

I am a beginer with Docker techno. I cannot build an nginx image. Here is what I do:
I want to check what nginx versions are available on my unbuntu

apt-cache madison nginx
nginx | 1.17.10-0ubuntu1 | http://eu-west-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 Packages

I can install this version without any problem:

sudo apt-get -y install nginx=1.17.10-0ubuntu1

so I try to build an image with it:

vi Dockerfile
FROM ubuntu:bionic

ENV NGINX_VERSION 1.17.10-0ubuntu1

RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y nginx=$NGINX_VERSION

CMD [“nginx”, “-g”,“daemon off;”]

but I always have got this error message:

[ …]
E: Version ‘1.17.10-0ubuntu1’ for ‘nginx’ was not found
[…]

thanx a lot folks !

two things:

you identified the package version on ubuntu focal, and try to install this version with a bionic base image. Either do your madison search on bionic or switch to a focal base image.

it is sufficient to run apt-get update once. apt-get install accepts more than a single package.

This will install the latest available nginx packge on a bionic base image:

    FROM ubuntu:bionic

    ARG NGINX_VERSION=1.14.0-0ubuntu1.7

    RUN apt-get update && \
        apt-get install -y curl nginx=${NGINX_VERSION}

    CMD ["nginx", "-g", "daemon off;"]

I switched the ENV to ARG, as the variable is only required during build time and irrelevant during container runtime.