I make a premise. I have installed Docker inside Ubuntu 22.04 and I have installed Ubuntu 22.04 inside a vmware VM. My goal is to build a well-equipped local server with Docker.
I have the following Docker project which works perfectly but has a very small problem. After starting the 3 containers I have to connect to pgAdmin and connect the software to the volume using this configuration:
I’ve read this page but haven’t found any environment variables that can help me skip this awkward step:
Besides, I also have another problem. After I have connected to the database I have to load the database schema.
Is it possible to register the server on pgAdmin as shown above and load a schema saved in a life schema.sql with Docker too? I would like to spare this second step again if possible.
I would like to get pgAdmin configured automatically like this:
(gis database with 3 tables)
All my docker project:
In the .war file:
{
"url": "jdbc:postgresql://localhost:5432/gis",
"user": "eb",
"password": "password"
}
/home/gi/Dropbox/SERVER/DOCKER-LINUX/Tomcat-PosgreSQL-PostGIS-PgAdmin/postgresql-postgis/Dockerfile
FROM kartoza/postgis:9.6-2.4
LABEL Author="Nome Cognome"
EXPOSE 5432
VOLUME create pg_data
/home/gi/Dropbox/SERVER/DOCKER-LINUX/Tomcat-PosgreSQL-PostGIS-PgAdmin/tomcat/Dockerfile
FROM tomcat:9.0.22-jdk13-openjdk-oracle
LABEL Author="Nome Cognome"
EXPOSE 8080
COPY ./*.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
/home/gi/Dropbox/SERVER/DOCKER-LINUX/Tomcat-PosgreSQL-PostGIS-PgAdmin/pgadmin
FROM dpage/pgadmin4:latest
LABEL Author="Nome Cognome"
EXPOSE 80
/home/gi/Dropbox/SERVER/DOCKER-LINUX/Tomcat-PosgreSQL-PostGIS-PgAdmin/docker-compose.yaml
version: '3.8'
services:
postgresql-postgis:
build: ./postgresql-postgis
image: image-postgresql-postgis-eb:v.1.0
container_name: container-postgresql-postgis-eb
ports:
- 5432:5432
volumes:
- pg_data:/var/lib/postgresql
environment:
POSTGRES_USER: "eb"
POSTGRES_PASS: "password"
POSTGRES_DBNAME: "gis"
ALLOW_IP_RANGE: "0.0.0.0/0"
restart: always
networks:
- eb
tomcat:
build: ./tomcat
image: image-tomcat-eb:v.1.0
container_name: container-tomcat-eb
ports:
- 8888:8080
depends_on:
- postgresql-postgis
restart: on-failure
networks:
- eb
pgadmin:
build: ./pgadmin
image: image-pgadmin-eb:1.0
container_name: container-pgadmin-eb
ports:
- 5050:80
environment:
PGADMIN_DEFAULT_EMAIL: admin@gmail.com
PGADMIN_DEFAULT_PASSWORD: password
depends_on:
- postgresql-postgis
restart: always
networks:
- eb
volumes:
pg_data:
networks:
eb: