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

/startapp.sh: not found #90

Closed erythrun closed 1 year ago

erythrun commented 1 year ago

follow the document get start, container cant start i have ensure the /startapp.sh exist and chmod with 755

log: [supervisor ] starting service 'app'... [app ] /etc/services.d/app/run: 7: exec: /startapp.sh: not found [supervisor ] all services started.

Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2

jlesage commented 1 year ago

The problem is not that /startapp.sh does not exist. The problem is what the script is executing. Are you trying to execute an executable built with glibc with an Alpine baseimage ?

jlesage commented 1 year ago

See #89, I think it's a similar issue.

jlesage commented 1 year ago

Did you resolve your issue ?

jlesage commented 1 year ago

Closing this issue. Please re-open if needed.

salamander2 commented 9 months ago

The problem is not that /startapp.sh does not exist. The problem is what the script is executing. Are you trying to execute an executable built with glibc with an Alpine baseimage ?

Hi. I'm trying to figure this stuff out. Why are you using a shell script instead of a Dockerfile CMD or ENTRYPOINT to run the app?

jlesage commented 9 months ago

Because starting the app alone doesn't work. The application needs other services (e.g. the X server).

So the containers needs to start and manage multiple processes, one of them being the app. This is done via an init system, started by the Dockerfile CMD.

salamander2 commented 9 months ago

Makes sense. It's really too bad, however, that there two separate files that need modifying each time you rebuild it.
For example, I'm trying to get a Swing Java program to work via your GUI. If I want to run another different Java program, I'd have to rebuild changing both the Dockerfile and the startapp.sh

What I think would be better, would be to use ENV varaibles to specify the info in startapp.sh and then startapp.sh just uses those. This way there is only one file to modify, and startapp.sh could be permanently installed in the image. (Of course, users could override it if they wanted a custom one).

Another alternative is to use docker compose. This allows "config" files. These files are copied to specified places when docker compose up" is RUN, not when it is BUILT.


Just FYI, here are my Dockerfile and startapp.sh (so far)

# Pull base image.
FROM jlesage/baseimage-gui:ubuntu-20.04

# Copy the minimized, premade JRE (here it's Java 11)
COPY jre_11 /opt/java/

WORKDIR /app
RUN echo 'alias ll="ls -l"' >> ~/.bashrc

ARG DOMAIN=ca/quarkphysics/harwood/

# Better to use a bind mount for class files
# Copy the class files ONLY to /app
COPY src/$DOMAIN/sciOlympics /app/$DOMAIN/sciOlympics

# Set the name of the application (for the Browser window)
ENV APP_NAME="SciOlympics Function ID"

# Copy the start script.
# NOTE this script needs to be updated to run the correct class file.
COPY startapp.sh /startapp.sh

#docker build -t sci_olympics .
#docker run --rm --restart=unless-stopped -p 5800:5800 -p 5900:5900 sci_olympics
#!/bin/sh
export HOME=/app
cd /app
exec /opt/java/bin/java ca.quarkphysics.harwood.sciOlympics.Function
jlesage commented 9 months ago

This project was not designed to run and support multiple apps per container. It focuses on providing an environment for a single app. It doesn't provide a "full desktop" experience. You might have a specific need where different apps share the same environment, but this is usually not the case.

Note that you can have a startapp.sh that uses an environment variable to select the program to start.

salamander2 commented 9 months ago

Hi. I know that this just runs one project per container. However, it is very flexible in that it's easy to change the project when needed.

Doing away with startapp.sh

I've now improved the startapp.sh . It's 3 lines and NEVER needs modification by the user. All of the modification gets done in the Dockerfile.

#!/bin/sh
cd $HOME
exec $APP_CMD

Dockerfile now has this:

# Set environment variables
ENV HOME="/app"
# use this form to make sure that the internal HOME variable is set
#RUN set-cont-env HOME "/app"

ENV APP_NAME="SciOlympics Function ID"
ENV APP_CMD="/opt/java/bin/java ca.quarkphysics.harwood.sciOlympics.Function"
JulianVallee commented 7 months ago

Just adding onto this in case others have the same problem: I was getting this error message because my startapp.sh had windows linebreaks (CR LF), switched to linux (LF) and now it works.