0
FROM ubuntu:bionic

ENV NGINX_VERSION 1.14.0-0ubuntu1.9

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;"]

trying to create a custom nginx docker image but getting error:

E: Version '1.14.0-0ubuntu1.9' for 'nginx' was not found
The command '/bin/sh -c apt-get update && apt-get install -y nginx=$NGINX_VERSION' returned a non-zero code: 100
Baba
  • 3,279
mixage
  • 1

1 Answers1

0

apt repositories usually only have a single version of a package for a given release; in your case, the bionic repositories currently provide version 1.14.0-0ubuntu1.11 of the nginx package.

In practice, this means that you should write your container file as follows:

FROM ubuntu:bionic

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

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

In fact, you can save a layer by merging both apt-get lines:

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

See Why do previous versions of Debian packages vanish in the package repositories? (highly relevant for version-controlled system configuration) for details; Ubuntu repositories have the same behaviour.

Stephen Kitt
  • 434,908