-1

I got postgresql and pgadmin4 with docker swarm on my ubuntu 18.04 server, but pgadmin gives me errors and after a while the application crashes and I can't enter postgres: this is the error

 PermissionError: [Errno 1] Operation not permitted: '/var/lib/pgadmin/sessions'
 WARNING: Failed to set ACL on the directory containing the configuration database:
    [Errno 1] Operation not permitted: '/var/lib/pgadmin'
 HINT   : You may need to manually set the permissions on
          /var/lib/pgadmin to allow pgadmin to write to it.
 /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
   return io.open(fd, *args, **kwargs)
 [2020-09-04 21:12:24 +0000] [1] [INFO] Shutting down: Master
 [2020-09-04 21:12:24 +0000] [1] [INFO] Reason: Worker failed to boot.
 WARNING: Failed to set ACL on the directory containing the configuration database:
            [Errno 1] Operation not permitted: '/var/lib/pgadmin'
 HINT   : You may need to manually set the permissions on
          /var/lib/pgadmin to allow pgadmin to write to it.
 NOTE: Configuring authentication for SERVER mode.

 sudo: setrlimit(RLIMIT_CORE): Operation not permitted
 [2020-09-04 21:14:26 +0000] [1] [INFO] Starting gunicorn 19.9.0
 [2020-09-04 21:14:26 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
 [2020-09-04 21:14:26 +0000] [1] [INFO] Using worker: threads
 /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
   return io.open(fd, *args, **kwargs)
 [2020-09-04 21:14:26 +0000] [89] [INFO] Booting worker with pid: 89

in error I see that it tells me NOTE: Configuring authentication for SERVER mode. but I don't know how to configure what it indicates, someone could help me solve my problem. Thank you

Edit:

docker-compose.yml

version: '3'
services:
  ssl:
       image: danieldent/nginx-ssl-proxy
       restart: always
       environment:
         UPSTREAM: myApp:8086
         SERVERNAME: dominio.com
       ports:
            - 80:80/tcp
            - 443:443/tcp
       depends_on:
            - myApp
       volumes:
            -  ./nginxAPP:/etc/letsencrypt
            -  ./nginxAPP:/etc/nginx/user.conf.d:ro
   bdd:
     restart: always
     image: postgres:12
     ports:
          - 5432:5432/tcp  
     environment:
         POSTGRES_USER: user
         POSTGRES_PASSWORD: 12345
         POSTGRES_DB: miBDD
     volumes:
          - ./pgdata:/var/lib/postgresql/data
  pgadmin:
    image: dpage/pgadmin4
    ports:
        - 9095:80/tcp
    environment:
       PGADMIN_DEFAULT_EMAIL: user
       PGADMIN_DEFAULT_PASSWORD: 12345
       PROXY_X_FOR_COUNT: 3
       PROXY_X_PROTO_COUNT: 3
       PROXY_X_HOST_COUNT: 3
       PROXY_X_PORT_COUNT: 3
    volumes:
      - ./pgadminAplicattion:/var/lib/pgadmin
  myApp:
   restart: always
   image: appImage 
   ports:    
         - 8086:8086
   depends_on:
       - bdd
   working_dir: /usr/myApp
   environment:
       CONFIG_PATH: ../configuation
   command: "node server.js"
Konrad Botor
  • 4,765
  • 1
  • 16
  • 26

2 Answers2

0

It's generally a bad idea to use bind mounts in a non-development environments and doubly so when it comes to Docker Swarm (as opposed to regular Docker). This goes doubly when it comes to images like postgres or dpage/pgadmin4, which require those mounted directories to have specific ownership and/or read/write priviledges.

In your case, you need to run:

sudo chown 999:999 pgdata
sudo chown 5050:5050 pgadminAplicattion

to give those directories correct ownership.

That being said, it's a much better idea to avoid bind mounts entirely and use named volumes instead (irrelevant parts of Compose file skipped):

version: "3"
services:
    bdd:
        restart: always
        image: postgres:12
        ports:
            - 5432:5432/tcp
        environment:
            POSTGRES_USER: user
            POSTGRES_PASSWORD: 12345
            POSTGRES_DB: miBDD
        volumes:
            - pgdata:/var/lib/postgresql/data
    pgadmin:
        restart: always
        image: dpage/pgadmin4
        ports:
            - 9095:80/tcp
        environment:
            PGADMIN_DEFAULT_EMAIL: user
            PGADMIN_DEFAULT_PASSWORD: 12345
            PROXY_X_FOR_COUNT: 3
            PROXY_X_PROTO_COUNT: 3
            PROXY_X_HOST_COUNT: 3
            PROXY_X_PORT_COUNT: 3
        volumes:
            - pgadmin:/var/lib/pgadmin
volumes:
    pgdata:
    pgadmin:
Konrad Botor
  • 4,765
  • 1
  • 16
  • 26
0

In your case you need to use following command: Try this

sudo chown -R 5050:5050 /var/lib/pgadmin
Syscall
  • 19,327
  • 10
  • 37
  • 52