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:

  • Docker tomcat8-jre8 hacked?
  • Linking Django and Postgresql with Docker
  • Bridged network connection in Dockerfile
  • Pika to RabbitMQ connection failure using Raspberry PI and Docker container
  • Docker ubuntu container can ping archive.ubuntu.com but not apt-get
  • How to push a named volume / share a named volume with other **PCs**?
  • 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 ??

  • Installing docker-ce through puppet
  • How can I fix Docker/Mac no space left on device error?
  • Assign static IP to Docker container
  • marathon instances are not running
  • Virtualize Kickstart Server
  • Docker compose new image and instance
  • 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.