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

Environment variables not sticking after container launch #54

Closed kennyparsons closed 3 years ago

kennyparsons commented 3 years ago

Hey @jlesage I am using your base image for a build of mine. Dockerfile below. Basically, it launches an instance of Thunderbird, which gives me the accessibility of webmail and the features of a desktop client. As Thunderbird profiles are launched from home directories, I mapped /config/app to a host directory containing the profile/settings. To test, I launched the container, with xterm as the startapp, set the home env with HOME=/config/app, and then proceeded to successfully launch thunderbird with thunderbird. With the test being successful, the last step is then to set the home directory for the user app (uid 1000) to /config/app within the dockerfile: ENV HOME="/config/app"

FROM jlesage/baseimage-gui:debian-10
RUN apt update && \
  apt upgrade -y && \
  apt install -y thunderbird

#Debugging purposes
Run apt install htop xterm -y
COPY startapp.sh /startapp.sh
ENV APP_NAME="Thunderbird"
ENV HOME="/cofig/app/"

However, upon logging into xterm as user app, HOME remains empty: Screen Shot 2021-04-23 at 2 55 05 PM

Can you tell me how/why this ENV isn't sticking or is getting overwritten? Thanks!

PS Love your work. Keep it up!

jlesage commented 3 years ago

You can try to set the environment variables in a single statement in your Dockerfile. For example:

ENV APP_NAME="Thunderbird" HOME="/config/app/"

Also, you may want to put your HOME variable directly inside the startapp.sh script instead, unless you want people to be able to change it.

kennyparsons commented 3 years ago

I tried putting in the Dockerfile (see my original post). Wasn't sure if anything would cause it to not stick when the image inits.

I ended up putting the env in the startup shell.