I have already opened many discussions on these volumes and I have read the documentation but I still have a lot of problems. I need concrete help to understand how to create these volumes in the right way. If you want to help me, I’m here and I thank you infinitely.
I use these images:
FROM openjdk:11.0.15-jre-slim
FROM dpage/pgadmin4:6.10
FROM kartoza/postgis:14-3.2-v2022.05.09
FROM postgres:14.3-alpine3.16
Find two similar images for the database because in reality the projects I’m creating are 2. On one project I need postgis and on the other I don’t.
I only have problems with the database image. The rest works.
The problems I encounter are the following:
- Locally when I delete the containers, the images and recreate both I also execute the following command:
docker volume ls
I notice that the volumes are more and more numerous each time. I believe Docker creates new volumes every time. - When I try to download the database volume from Real Cloud with FileZilla (this does not happen for the other volumes) the program writes me:
Error: Directory/home/ubuntu/ServerDockerJava01/volumes/data-postgresql/14/main: permission denied
Error: Failed to retrieve directory listing
- Docker continually creates this folder but I didn’t tell you to:
/home/gi/volumes/data_java
- When I connect to linux the operating system asks me for the root password (see attached photo).
- With ‘postgres: 14.3-alpine3.16’ I can’t use ‘target: /var/lib/postgresql’ but I have to use ‘target: /var/lib/postgresql/data’. It is possible to create the volume of the folder ‘postgresql’ and not of the folder ‘data’.
- When I stop the linux VM that I use locally on vmware and on which I try docker and then I turn it back on I have to delete all containers and all images and then recreate everything otherwise I get database connection problems.
How can I do this?
My code:
version: '3.9'
services:
postgresql-postgis:
build: ./postgresql-postgis
image: image-postgresql-postgis-eb:v.1.0
container_name: container-postgresql-postgis-eb
ports:
- 5432:5432
volumes:
- type: bind
source: ./volumes/data-postgresql
target: /var/lib/postgresql/data
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password"
POSTGRES_DB: "nomedb"
ALLOW_IP_RANGE: "0.0.0.0/0"
restart: always
networks:
- eb
pgadmin:
...
volumes:
- type: bind
source: ./volumes/data-pgadmin/servers.json
target: /pgadmin4/servers.json
environment:
PGADMIN_DEFAULT_EMAIL: admin@gmail.com
PGADMIN_DEFAULT_PASSWORD: password
...
java:
...
volumes:
- type: bind
source: ./volumes/data-java
target: /appfolder
...
networks:
eb:
Dockerfile for DB:
FROM postgres:14.3-alpine3.16
# FROM kartoza/postgis:14-3.2--v2022.05.09
EXPOSE 5432