2015-09-13 140 views
0

我有一个要求,可以创建启用postGISpostgresql数据库的自定义码头镜像。现在,这是一个已经存在的图像,这是HERE,但这是给我的任务,所以我必须做我自己的码头文件和图像。我试过如下:我正在尝试构建Docker postgres镜像时出现错误

mkdir postgres 
cd postgres 
touch Dockerfile 

现在我编辑Dockerfile和编辑它如下所示:

FROM postgres:9.4 
MAINTAINER Mike Dillon <[email protected]> 

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可以看作HERE了。

基本上,dockrfile与mdillon/postgis图像相同。

现在,当我运行构建命令,如下所示:

docker build -t gautam/postgresql:v1 . 

我收到以下错误:

E:无法找到包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 

为什么?

回答

1

因为你应该删除斜杠或在他们之后做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$ 
+0

@Mykolagurow,现在我得到一个错误'未知的指令:POSTGRESQL- $ PG_MAJOR-POSTGIS- $ POSTGIS_MAJOR = $ POSTGIS_VERSION ',我的搬运工文件看起来像这样http://chopapp.com/#yhgzfw54 –

+0

亚历山大,你的链接不起作用。我想你可以和你自己提供的例子进行比较,这个例子正在工作。注意缩进和行尾。 –

+0

该链接将在2-3分钟内加载,并保持标签打开;) –

相关问题