UnauthorizedAccessBV / ESET-Protect-Docker-Server

MIT License
12 stars 3 forks source link

cannot run ESET-Protect-Docker-Server if configuration folder is binded #1

Closed rhenT closed 7 months ago

rhenT commented 2 years ago

Dear @dmaasland ,

I wanted to run ESET-Protect-Docker-Server on my Synology NAS and binded the folders /config, /data and /log to a local folder on the NAS. (I've tried it on Debian 11 too) I've seen that you have hard coded the PUID and GUID to 3537 so I changed the owner of the folder to the UID's in the docker image, but I can't get it to work.

For me it seems like load_config method in run.py seems to be called earlier (in init phase) than check if the install is a new install:

Traceback (most recent call last):
  File "/run.py", line 397, in <module>
    main()
  File "/run.py", line 377, in main
    current_install = CurrentInstall()
  File "/run.py", line 67, in __init__
    self.load_config()
  File "/run.py", line 73, in load_config
    with open("/config/config.cfg", "r") as config_file:

This is strange because if I am not defining any mounting point the image seems to start normally. Can you please check if you can fix this issue?

Thank you, Tamas

dmaasland commented 2 years ago

I think this is because when you bind mount a volume it doesn't actually creates the files it needs. I've run into this a few times in the past but I'm not enough of a Docker guru to fix it. I will dive into this and let you know if I find anything.

It's not a solution but using this docker compose file does the trick for me:

version: '3'

services:
    ep-db:
        image: mysql:8.0.17
        command: |
            --default-authentication-plugin=mysql_native_password
            --innodb-log-file-size=100M
            --innodb-log-files-in-group=2
            --max-allowed-packet=30M
            --bind-address=*
            --log_bin_trust_function_creators=1
        restart: unless-stopped
        environment:
            - MYSQL_ROOT_USER=root
            - MYSQL_ROOT_PASSWORD=eraadmin
        volumes:
            - ep-db:/var/lib/mysql

    ep-server:
        image: esetnederland/eset-protect-server
        depends_on:
            - ep-db
        restart: unless-stopped
        environment:
            - DB_ADMIN_USERNAME=root
            - DB_ADMIN_PASSWORD=eraadmin
            - DB_HOSTNAME=ep-db
        volumes:
            - ep-server-config:/config
            - ep-server-data:/data
            - ep-server-logs:/logs
        ports:
            - 2222:2222

    ep-console:
        image: esetnederland/eset-protect-console
        depends_on:
            - ep-server
        restart: unless-stopped
        environment:
          - ESMC_SERVER=ep-server
        volumes:
            - ep-console:/config
        ports:
            - 8080:8080

volumes:
    ep-db:
    ep-server-config:
    ep-server-data:
    ep-server-logs:
    ep-console:
bjohnson8949 commented 2 years ago

I am 99% sure this because of permission issues. I haven't tested this yet but you should be able to

chown -R 3537 :3537 /your/folder/mount/point

jasonpstokes commented 2 years ago

@rhenT Did you find a solution for this please? I'm also trying to use local paths for these containers. The docker containers work with volumes, but not with direct paths - even if the folder/file ownership is set to 3527.

dmaasland commented 2 years ago

Unfortunately, that's just a consequence of how Docker handles bind volumes. If you want to use a specific folder I suggest setting up a named volume with a local path:

version: '3'

services:
    ep-db:
        image: mysql:8.0.17
        command: |
            --default-authentication-plugin=mysql_native_password
            --innodb-log-file-size=100M
            --innodb-log-files-in-group=2
            --max-allowed-packet=30M
            --bind-address=*
            --log_bin_trust_function_creators=1
        restart: unless-stopped
        environment:
            - MYSQL_ROOT_USER=root
            - MYSQL_ROOT_PASSWORD=eraadmin
        volumes:
            - ep-db:/var/lib/mysql

    ep-server:
        image: esetnederland/eset-protect-server
        depends_on:
            - ep-db
        restart: unless-stopped
        environment:
            - DB_ADMIN_USERNAME=root
            - DB_ADMIN_PASSWORD=eraadmin
            - DB_HOSTNAME=ep-db
        volumes:
            - ep-server-config:/config
            - ep-server-data:/data
            - ep-server-logs:/logs
        ports:
            - 2222:2222

    ep-console:
        image: esetnederland/eset-protect-console
        depends_on:
            - ep-server
        restart: unless-stopped
        environment:
          - ESMC_SERVER=ep-server
        volumes:
            - ep-console:/config
        ports:
            - 8080:8080

volumes:
    ep-db:
    ep-server-config:
        driver_opts:
            o: bind
            type: none
            device: /tmp/ep-server-config
    ep-server-data:
        driver_opts:
            o: bind
            type: none
            device: /tmp/ep-server-data
    ep-server-logs:
        driver_opts:
            o: bind
            type: none
            device: /tmp/ep-server-logs
    ep-console:

You will still need to create these directories manually:

mkdir /tmp/ep-server-{config,data,logs}