我需要构建一个支持postGIS的PostgreSQL数据库的自定义docker映像。现在有一个已经存在的镜像,does this here;然而,这是给我的一个任务,所以我必须创建我自己的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的can be viewed here也是如此。
Dockerfile文件基本上与mdillon/postgis镜像文件相同。
现在,当我运行build命令时,如下所示:
docker build -t gautam/postgresql:v1 .我得到以下错误:
E: Unable to locate package 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为什么会这样呢?
发布于 2015-09-13 23:50:11
因为您应该删除斜杠或在斜杠之后执行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$https://stackoverflow.com/questions/32550948
复制相似问题