I am getting an error when i am trying to build my Docker postgres image

I have a requirement to build a custom docker image of a postgresql database that is postGIS enabled. Now there is this is an already existing image that does this HERE , But this is an assignment given to me and so i have to make my own docker file and image. What i tried is as follows:

mkdir postgres
cd postgres
touch Dockerfile

now i edit the Dockerfile and edited it look as follows:

  • Setting up docker-compose, uwsgi, Django and nginx, for Pycharm, makes nginx return 502 Bad Gateway
  • How to read and write to mounted volume without running as root?
  • Permission Denied while trying to connect to Docker Daemon while running Jenkins pipeline in Macbook
  • pull image from remote registry - docker
  • Redeploy spring-boot application in docker container?
  • When running Docker on Raspberry Pi starting containers fails from time to time
  • 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;"
    

    The dockerfile can be viewed HERE too.

    Basically the dockrfile is the same as the mdillon/postgis image.

    Now when i run the build command as follows:

    docker build -t gautam/postgresql:v1 .
    

    I get the following error:

    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
    

    Why ??

  • Node.js in container always get the docker0 ip
  • Is there a straight way to get html response from a unix socket in Go (like curl does)?
  • 'Kubectl' throws error 'failed to negotiate an api version' while installing using docker
  • How to configure exim with docker for sendmail
  • Docker + Marathon : how to do a port mapping ?
  • Docker registry notifications multiple push
  • One Solution collect form web for “I am getting an error when i am trying to build my Docker postgres image”

    because you should either remove slashes or do cr/lf after them.

    #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$
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.