我正在尝试构buildDocker postgres映像时遇到错误

我有一个要求,build立postGIS数据库的postGIS启用自定义docker的形象。 现在有一个已经存在的图像在这里做这个,但这是给我的任务,所以我必须做我自己的docker文件和图像。 我试过的如下:

 mkdir postgres cd postgres touch Dockerfile 

现在我编辑Dockerfile并编辑它看起来如下所示:

 FROM postgres:9.4 MAINTAINER Mike Dillon <mike@appropriate.io> ENV POSTGIS_MAJOR 2.1 ENV POSTGIS_VERSION 2.1.7+dfsg-3~94.git954a8d0.pgdg80+1 RUN apt-get update && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgis=$POST$ RUN mkdir -p /docker-entrypoint-initdb.d COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh # Optional: Drop database RUN dropdb -U postgres pgrouting-workshop # Create a new routing database 16 RUN createdb -U postgres pgrouting-workshop RUN psql -U user -d pgrouting-workshop -c "CREATE EXTENSION postgis;" RUN psql -U user -d pgrouting-workshop -c "CREATE EXTENSION pgrouting;" 

dockerfile也可以在这里查看。

dockrfile基本上和mdillon / postgis镜像一样。

现在,当我运行生成命令如下:

 docker build -t gautam/postgresql:v1 . 

我得到以下错误:

E:无法find软件包postgresql-9.4-postgis-2.1

 E: Couldn't find any package by regex ' postgresql-9.4-postgis-2.1' E: Unable to locate package postgis E: Unable to locate package The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgis=$POSTGIS_VERSION \ && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100 

为什么?

因为你应该删除斜杠或者在他们之后做cr / lf。

 #good RUN apt-get update && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION postgis=$POST$ #good RUN apt-get update && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgis=$POST$ #bad RUN apt-get update && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgis=$POST$