I created a dockerfile in order to make my kartoza/postgis
image installation custom. My dockerfile should copy geotif images to a folder in the container and then run a combando of the raster2pgsql
application in a pipe with the command PGPASSWORD=password psql -h localhost -p 5432 -U admin -d elevation
ossia:
RUN sh -c raster2pgsql -s 4326 -C -F -I -t 100x100 /var/dem/w*.tif public.italy | PGPASSWORD=password psql -h localhost -p 5432 -U admin -d elevation
At this point I get the following error message:
C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe -f G:\spring-boot-elevation-finder\elevation-finder\docker-compose.yaml -p elevation-finder up -d
2023/07/04 20:58:56 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
[+] Building 1.3s (8/8) FINISHED
=> [postgis internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [postgis internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.14kB 0.0s
=> [postgis internal] load metadata for docker.io/kartoza/postgis:latest 0.6s
=> [postgis internal] load build context 0.0s
=> => transferring context: 105B 0.0s
=> [postgis 1/3] FROM docker.io/kartoza/postgis@sha256:1360f5d3dcb2de05e8f6ced767e26a5f29344876a9ef119f1a3a69c9583eceda 0.0s
=> => resolve docker.io/kartoza/postgis@sha256:1360f5d3dcb2de05e8f6ced767e26a5f29344876a9ef119f1a3a69c9583eceda 0.0s
=> CACHED [postgis 2/3] RUN apt-get update && apt-get install -y gdal-bin postgis nano && apt-get clean && apt-get -y autoremove && rm -rf /var 0.0s
=> CACHED [postgis 3/3] COPY ./dem/* /var/dem/ 0.0s
=> [postgis] exporting to image 0.6s
=> => exporting layers 0.6s
=> => writing image sha256:17f8d7a48a38c7d375847f9d79c50c7a065f76ecdb306b2f2097e31b0231724a 0.0s
=> => naming to docker.io/library/elevation-finder-postgis 0.0s
[+] Running 1/1
[+] Running 3/4evation-finder_postgis_network Created 0.9
✔ Network elevation-finder_postgis_network Created 0.9s Container cloudbeaver_container Creating 0.0s
[+] Running 1/4cloudbeaver_container Created 0.1
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 1/4evation-finder_postgis_network Created 0.9
[+] Running 2/4evation-finder_postgis_network Created 0.9
✔ Network elevation-finder_postgis_network Created 0.9
[+] Running 2/4oudbeaver_container Starting 2.5s
✔ Network elevation-finder_postgis_network Created 0.9
[+] Running 4/4admin4_container Starting 2.5s
✔ Network elevation-finder_postgis_network Created 0.9s Container pgadmin4_container Starting 2.6s
✔ Container cloudbeaver_container Started 2.6s Container pgadmin4_container Starting 2.7s
✔ Container postgis Started 2.7s
✔ Container pgadmin4_container Started 2.8s
C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe -f G:\spring-boot-elevation-finder\elevation-finder\docker-compose.yaml -p elevation-finder up -d
[+] Building 8.2s (8/8) FINISHED
=> [postgis internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [postgis internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 1.14kB 0.0s
=> [postgis internal] load metadata for docker.io/kartoza/postgis:latest 1.6s
=> [postgis 1/4] FROM docker.io/kartoza/postgis@sha256:1360f5d3dcb2de05e8f6ced767e26a5f29344876a9ef119f1a3a69c9583eceda 0.0s
=> => resolve docker.io/kartoza/postgis@sha256:1360f5d3dcb2de05e8f6ced767e26a5f29344876a9ef119f1a3a69c9583eceda 0.0s
=> [postgis internal] load build context 0.0s
=> => transferring context: 105B 0.0s
=> CACHED [postgis 2/4] RUN apt-get update && apt-get install -y gdal-bin postgis nano && apt-get clean && apt-get -y autoremove && rm -rf /var 0.0s
=> CACHED [postgis 3/4] COPY ./dem/* /var/dem/ 0.0s
=> ERROR [postgis 4/4] RUN sh -c raster2pgsql -s 4326 -C -F -I -t 100x100 /var/dem/w*.tif public.italy | PGPASSWORD=password psql -h localhost -p 54 5.6s
------
> [postgis 4/4] RUN sh -c raster2pgsql -s 4326 -C -F -I -t 100x100 /var/dem/w*.tif public.italy | PGPASSWORD=password psql -h localhost -p 5432 -U admin -d elevation:
#0 2.358 psql: error: could not connect to server: Connection refused
#0 2.358 Is the server running on host "localhost" (127.0.0.1) and accepting
#0 2.358 TCP/IP connections on port 5432?
#0 2.358 could not connect to server: Cannot assign requested address
#0 2.358 Is the server running on host "localhost" (::1) and accepting
#0 2.358 TCP/IP connections on port 5432?
------
failed to solve: process "/bin/sh -c sh -c raster2pgsql -s 4326 -C -F -I -t 100x100 /var/dem/w*.tif public.italy | PGPASSWORD=password psql -h localhost -p 5432 -U admin -d elevation" did not complete successfully: exit code: 2
`docker-compose` process finished with exit code 17
Docker-compose
version: "3.8"
#name: my-project-name
services:
postgis:
build:
context: .
dockerfile: ./Dockerfile
# image: kartoza/postgis:${POSTGIS_VERSION_TAG}
container_name: postgis
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASS=${POSTGRES_PASS}
- POSTGRES_DB=${POSTGRES_DB}
- ALLOW_IP_RANGE=${POSTGRES_ALLOW_IP_RANGE}
- POSTGRES_MULTIPLE_EXTENSIONS=${POSTGRES_MULTIPLE_EXTENSIONS}
- POSTGRES_DATA_VOLUME:${POSTGRES_DATA_VOLUME}
restart: on-failure
volumes:
- postgis-data:${POSTGRES_DATA_VOLUME}
networks:
- postgis_network
pgadmin:
image: dpage/pgadmin4:${PGADIM_VERION_TAG}
container_name: ${PGADIM_CONTAINER_NAME}
ports:
- "5050:80"
restart: always
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
- PGADMIN_CONFIG_SERVER_MODE:${PGADMIN_CONFIG_SERVER_MODE}
networks:
- postgis_network
volumes:
- pgadmin-data:${PGADIM_DATA_VOLUME}
#depends_on:
#postgis:
#condition: service_healthy
cloudbeaver:
image: dbeaver/cloudbeaver:23.1.0
container_name: cloudbeaver_container
restart: always
ports:
- "8085:8978"
volumes:
- cloudbeaver-data:/opt/cloudbeaver/workspace
networks:
- postgis_network
volumes:
postgis-data:
pgadmin-data:
cloudbeaver-data:
networks:
postgis_network:
driver: bridge
Dockerfile
FROM kartoza/postgis
RUN apt-get update && apt-get install -y gdal-bin postgis nano\
&& apt-get clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*
COPY ./dem/* /var/dem/
RUN sh -c raster2pgsql -s 4326 -C -F -I -t 100x100 /var/dem/w*.tif public.italy | PGPASSWORD=password psql -h localhost -p 5432 -U admin -d elevation
.ENVI
POSTGIS_VERSION_TAG=15-3.3
POSTGRES_USER=admin
POSTGRES_PASS=password
POSTGRES_DB=elevation
POSTGRES_ALLOW_IP_RANGE=0.0.0.0/0
POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
POSTGRES_DATA_VOLUME=/var/lib/postgresql
PGADIM_VERION_TAG=6.14
PGADIM_CONTAINER_NAME=pgadmin4_container
PGADMIN_DEFAULT_EMAIL=admin@admin.com
PGADMIN_DEFAULT_PASSWORD=admin
PGADMIN_CONFIG_SERVER_MODE=False
PGADMIN_PORT=5050
PGADIM_DATA_VOLUME=/var/lib/pgadmin