簡體   English   中英

嘗試構建Docker Postgres映像時出現錯誤

[英]I am getting an error when I am trying to build my Docker Postgres image

我需要構建啟用了postGIS的PostgreSQL數據庫的自定義postGIS 現在這是一個已經存在的圖像, 可以在此處執行 但是,這是給我的任務,因此我必須制作自己的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 也可以在這里查看

基本上,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

為什么是這樣?

因為您應該刪除斜線或在斜線之后執行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$

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM