Ravinou / borgwarehouse

A fast and modern WebUI for a BorgBackup's central repository server.
https://borgwarehouse.com
GNU Affero General Public License v3.0
381 stars 22 forks source link

Failed to start custom docker image - exec: "./docker-bw-init.sh": permission denied: unknown #146

Closed televisi closed 7 months ago

televisi commented 8 months ago

Hi, I'm running docker in QNAP server and trying to build my own docker image.

The following is my docker-compose.yml:

version: '3'
services:
    borgwarehouse:
        container_name: borgwarehouse
        # If you want to build the image yourself, uncomment the following lines and comment the image line
        build:
           context: .
           dockerfile: Dockerfile
           args:
               - UID=${UID}
               - GID=${GID}
        #image: borgwarehouse/borgwarehouse
        user: '${UID:?UID variable missing}:${GID:?GID variable missing}'
        ports:
            - '${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000'
            - '${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22'
        env_file:
            - .env
        volumes:
            - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config
            - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh
            - ${SSH_HOST:?SSH_HOST variable missing}:/etc/ssh
            - ${BORG_REPOSITORY_PATH:?BORG_REPOSITORY_PATH variable missing}:/home/borgwarehouse/repos
            - ${TMP_PATH:?TMP_PATH variable missing}:/home/borgwarehouse/tmp
            - ${LOGS_PATH:?LOGS_PATH variable missing}:/home/borgwarehouse/logs
    # Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse.
    apprise:
        container_name: apprise
        image: caronc/apprise
        user: 'www-data:www-data'

The following is my .ENV configuration:

## Required variables section ##
# Host port mappings
WEB_SERVER_PORT=15000
SSH_SERVER_PORT=15001

# Hostname and URL
FQDN=192.168.1.26
NEXTAUTH_URL=https://192.168.1.26:13500

# Secrects
NEXTAUTH_SECRET=aa
CRONJOB_KEY=aa

# UID:GID must match the user and group ID of the host folders and must be > 1000
# If you want to use a different user than 1001:1001, you must rebuild the image yourself.
UID=1002
GID=1002

# Config and data folders (volume mounts)
# The host folders must be owned by the user with UID and GID specified above
CONFIG_PATH=/share/Container-Data/borgwarehouse/config
SSH_PATH=/share/Container-Data/borgwarehouse/ssh
SSH_HOST=/share/Container-Data/borgwarehouse/etcssh
BORG_REPOSITORY_PATH=/share/Container-Data/borgwarehouse/repository
TMP_PATH=/share/Container-Data/borgwarehouse/tmp
LOGS_PATH=/share/Container-Data/borgwarehouse/logs

upon docker compose, it threw this error towards the end:

Error response from daemon: failed to create shim task: 
OCI runtime create failed: runc create failed: unable to start container process: 
exec: "./docker-bw-init.sh": permission denied: unknown

I checked the port 15000 and 15001 and both are not currently used. I also checked the current QNAP UID and GUID, none of them are being used too

What would be the issue here?

Thank you

Ravinou commented 8 months ago

Hi @televisi , your log is clear, you have a permission problem to execute the file: "./docker-bw-init.sh": permission denied.

Check that all files on your QNAP belong to your user (I don't know these NAS).

Ravinou commented 8 months ago

@televisi any news ?

televisi commented 8 months ago

@televisi any news ?

Apologies, will check this later tonight

televisi commented 8 months ago

@televisi any news ?

I'm a bit puzzled with this. The following is the id result when I ran it through QNAP CLI:

$ id
uid=1000(jhs) gid=100(everyone) groups=0(administrators),100(everyone)

When I updated the .env file with:

...
UID=1000
GID=100
...

The following is the error when I ran docker compose up -d:

 > [runner  2/11] RUN groupadd -g 100 borgwarehouse && useradd -m -u 1000 -g 100 borgwarehouse:
#0 24.27 groupadd: GID '100' already exists
------
failed to solve: executor failed running [/bin/sh -c groupadd -g ${GID} borgwarehouse && useradd -m -u ${UID} -g ${GID} borgwarehouse]: exit code: 4

What do you think could be the problem here? Thanks

Ravinou commented 8 months ago

Did you build your own image as it's describe here ?

televisi commented 8 months ago

Did you build your own image as it's describe here ?

Okay, I restarted the whole process again:

  1. Get the latest script from github

    git clone https://github.com/Ravinou/borgwarehouse.git
    cd borgwarehouse
  2. Edit docker-compose.yml with:

    version: '3'
    services:
    borgwarehouse:
        container_name: borgwarehouse
        # If you want to build the image yourself, uncomment the following lines and comment the image line
        build:
           context: .
           dockerfile: Dockerfile
           args:
               - UID=${UID}
               - GID=${GID}
        #image: borgwarehouse/borgwarehouse
        user: '${UID:?UID variable missing}:${GID:?GID variable missing}'
        ports:
            - '${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000'
            - '${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22'
        env_file:
            - .env
        volumes:
            - ${CONFIG_PATH:?CONFIG_PATH variable missing}:/home/borgwarehouse/app/config
            - ${SSH_PATH:?SSH_PATH variable missing}:/home/borgwarehouse/.ssh
            - ${SSH_HOST:?SSH_HOST variable missing}:/etc/ssh
            - ${BORG_REPOSITORY_PATH:?BORG_REPOSITORY_PATH variable missing}:/home/borgwarehouse/repos
            - ${TMP_PATH:?TMP_PATH variable missing}:/home/borgwarehouse/tmp
            - ${LOGS_PATH:?LOGS_PATH variable missing}:/home/borgwarehouse/logs
    # Apprise is used to send notifications, it's optional. http://apprise:8000 is the URL to use in BorgWarehouse.
    apprise:
        container_name: apprise
        image: caronc/apprise
        user: 'www-data:www-data'
  3. edit .env file:

    
    ## Required variables section ##

Host port mappings

WEB_SERVER_PORT=15000 SSH_SERVER_PORT=15001

Hostname and URL

FQDN=192.168.1.26 NEXTAUTH_URL=https://192.168.1.26:13500

Secrects

NEXTAUTH_SECRET=aa CRONJOB_KEY=aa

UID:GID must match the user and group ID of the host folders and must be > 1000

If you want to use a different user than 1001:1001, you must rebuild the image yourself.

UID=2500 GID=2501

Config and data folders (volume mounts)

The host folders must be owned by the user with UID and GID specified above

CONFIG_PATH=/share/Container-Data/borgwarehouse/config SSH_PATH=/share/Container-Data/borgwarehouse/ssh SSH_HOST=/share/Container-Data/borgwarehouse/etcssh BORG_REPOSITORY_PATH=/share/Container-Data/borgwarehouse/repository TMP_PATH=/share/Container-Data/borgwarehouse/tmp LOGS_PATH=/share/Container-Data/borgwarehouse/logs


4. Run ```docker compose up -d```

[+] Running 18/18 ⠿ borgwarehouse Pulled 167.8s ⠿ e1caac4eb9d2 Already exists 0.0s ⠿ 6e4d260b7fd8 Already exists 0.0s ⠿ 87a901ded22b Already exists 0.0s ⠿ fb54ee93c1ee Already exists 0.0s ⠿ 6d24a325c4fd Already exists 0.0s ⠿ 8f1a2a28f127 Pull complete 14.1s ⠿ 5eba1fe6be00 Pull complete 58.8s ⠿ d625489bc9b1 Pull complete 62.4s ⠿ f768f5ecc7be Pull complete 69.8s ⠿ c6264e84c217 Pull complete 77.0s ⠿ d9d8ffcc323f Pull complete 86.4s ⠿ 0636458822b1 Pull complete 91.7s ⠿ 06c03850f603 Pull complete 102.6s ⠿ ece0e91a01b7 Pull complete 108.7s ⠿ cf6340295506 Pull complete 113.5s ⠿ 2c03b6f3b185 Pull complete 117.7s ⠿ f5e116ef36a4 Pull complete 122.7s [+] Running 2/2 ⠿ Container apprise Started 77.9s ⠿ Container borgwarehouse Started 74.6s


```appraise``` container seems run okay, the following is its log:

2024-02-18 12:48:41,279 INFO Set uid to user 33 succeeded 2024-02-18 12:48:41,302 INFO supervisord started with pid 1 2024-02-18 12:48:42,304 INFO spawned: 'gunicorn' with pid 7 2024-02-18 12:48:42,305 INFO spawned: 'nginx' with pid 8 2024-02-18 12:48:43,307 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2024-02-18 12:48:43,307 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) [2024-02-18 12:48:45 +0000] [7] [INFO] Starting gunicorn 21.2.0 [2024-02-18 12:48:45 +0000] [7] [INFO] Listening at: http://0.0.0.0:8080 (7) [2024-02-18 12:48:45 +0000] [7] [INFO] Using worker: gevent [2024-02-18 12:48:45 +0000] [13] [INFO] Booting worker with pid: 13 [2024-02-18 12:48:45 +0000] [14] [INFO] Booting worker with pid: 14 [2024-02-18 12:48:45 +0000] [15] [INFO] Booting worker with pid: 15 [2024-02-18 12:48:45 +0000] [16] [INFO] Booting worker with pid: 16 [2024-02-18 12:48:45 +0000] [17] [INFO] Booting worker with pid: 17 [2024-02-18 12:48:45 +0000] [18] [INFO] Booting worker with pid: 18 [2024-02-18 12:48:45 +0000] [19] [INFO] Booting worker with pid: 19 [2024-02-18 12:48:46 +0000] [20] [INFO] Booting worker with pid: 20 [2024-02-18 12:48:46 +0000] [21] [INFO] Booting worker with pid: 21


When I checked ```borgwarehouse``` container, it was in ```exited``` status; when I checked the container log, the following was displayed:

/etc/ssh is empty, generating SSH host keys... No user exists for uid 2500



I'm confused now... did I miss anything?
Thanks
Ravinou commented 8 months ago

Do you see a building step like this ? image

It looks as though your container is based on an image that already exists, either on your PC or retrieved from dockerhub.

Ravinou commented 8 months ago

?