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:

  • Postrgesql running on coreos
  • Should I containerize a standalone command-line or terminal application which requires 16 vCPU?
  • Different hashes while pulling from hub and pushing to registry
  • How can ichange a virtualbox configuration using docker-machine
  • Register an instance to an AWS ECS cluster
  • Which platform is mostly used in production servers to develop and deploy “application services” [closed]
  • 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 ??

  • Docker over Linux but running Windows inside
  • Can't ping Docker containers via hostnames/names
  • Docker, aufs, and unattended-upgrades
  • Intellij, Spring dev tools remote, Docker, error Unexpected 404 response uploading class files
  • PHP file not found that should be found according to configured vHost
  • Trouble deploying docker on AWS with ecs-cli
  • 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.