jlesage / docker-baseimage-gui

A minimal docker baseimage to ease creation of X graphical application containers
MIT License
1.2k stars 179 forks source link

/bin/sh: can't open '/startapp.sh': Permission denied #89

Closed ovizii closed 1 year ago

ovizii commented 1 year ago

Trying my hand with baseimage-gui:alpine-3.17-v4 and https://obsidian.md/download

Dockerfile

# Pull base image.                                                                                                                                   
FROM jlesage/baseimage-gui:alpine-3.17-v4                                                                                                            

# set obsidian version                                                                                                                               
ARG OBSIDIAN_VERSION=1.1.9                                                                                                                           

# Install http-server.                                                                                                                               
RUN apk add --upgrade apk-tools && \                                                                                                                 
    apk upgrade --available && \                                                                                                                     
    apk add curl nss dbus-x11 libuuid git && \                                                                                                       
    mkdir /opt/obsidian && \                                                                                                                         
    cd /opt/obsidian && \                                                                                                                            
    echo "**** download obsidian ****" && \                                                                                                          
    curl \                                                                                                                                           
    https://github.com/obsidianmd/obsidian-releases/releases/download/v$OBSIDIAN_VERSION/Obsidian-$OBSIDIAN_VERSION.AppImage \                       
    -L \                                                                                                                                             
    -o obsidian.AppImage && \                                                                                                                        
    chmod +x obsidian.AppImage                                                                                                                       

ENV CUSTOM_PORT="8089" \                                                                                                                             
    GUIAUTOSTART="true" \                                                                                                                            
    HOME="/vaults" \                                                                                                                                 
    TITLE="Obsidian v$OBSIDIAN_VERSION" \                                                                                                            
    USER_ID="1000" \                                                                                                                                 
    GROUP_ID="1000"                                                                                                                                  

# Copy the start script.                                                                                                                             
COPY startapp.sh /startapp.sh                                                                                                                        

# Set the name of the application.                                                                                                                   
RUN set-cont-env APP_NAME "obsidian"                                                                                                                 

EXPOSE 8089                                                                                                                                          
EXPOSE 27123                                                                                                                                         
EXPOSE 27124                                                                                                                                         
VOLUME ["/config","/vaults"] 

tried building it, saw no errors: docker build -t obsidian .

I've cobbled this together and am unsure about many things, but I can't make any progress since I get:

...
[nginx       ] Listening for HTTP connections on port 5800.                                                                                          
[supervisor  ] starting service 'app'...                                                                                                             
[app         ] /bin/sh: can't open '/startapp.sh': Permission denied                                                                                 
[supervisor  ] all services started.                                                                                                                 
[supervisor  ] service 'app' exited (with status 2).                                                                                                 
[supervisor  ] service 'app' exited, shutting down... 
...

I tried running it like this: docker run --rm -p 5809:8089 -e USER_ID=1000 -e GROUP_ID=1000 --name obsidian obsidian

startapp.sh

#!/bin/sh                                                                                                                                            
exec /opt/obsidian.AppImage --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer

btw. on my first tries, startapp.sh had a chmod 770 applied to it and I got this error:

[supervisor  ] starting service 'app'...                                                                                                             
[app         ] /!\ No application to start: /startapp.sh is missing or not executable. /!\                                                           
[supervisor  ] all services started

After a chmod +x applied to it, I am now getting: /bin/sh: can't open '/startapp.sh': Permission denied

Looking for some tips on what I am doing wrong ehre.

jlesage commented 1 year ago

The obsidian.AppImage binary is using glibc instead of musl, which is what Alpine uses. You can try to install libc6-compat or gcompat to see if it's working better. Other solutions are to build the binary yourself from sources, or use a ubuntu/debian baseimage.

ovizii commented 1 year ago

Thanks, I'll try your advice but still, do you have any idea what's going on here with the ownership and permissions of startapp.sh?

jlesage commented 1 year ago

In your source tree, a chmod 755 of startapp.sh should do the job.

If permissions on the file are good, you won't get the error /!\ No application to start: /startapp.sh is missing or not executable. /!\.

Other Permission denied related errors are related to the executable startapp.sh tries to execute.

avannus commented 1 year ago

In your source tree, a chmod 755 of startapp.sh should do the job.

If permissions on the file are good, you won't get the error /!\ No application to start: /startapp.sh is missing or not executable. /!\.

Other Permission denied related errors are related to the executable startapp.sh tries to execute.

This solved a problem for me upgrading from Ubuntu-20.04 v3 to v4, thanks!