How do I commit the user's Theia preferences to Docker?

One user comes in to configure the Theia UI, changing preferences, adding panels, etc. I want that state to be saved in the Docker image so the next user to start a container from that image would see the same set of panels.

Is this possible? How would you recommend doing it?

[original thread by Brian Dant]

[varmanishant]

{HOME}/.theia in your docker would be having those settings saved in settings.json if I am not mistaken … You can cross-check that and share it across. You can also create an image (not recommended) from the container you have right now using commit; but please make sure there is no private data inside the container like your SSH keys etc.

[Brian Dant]

Thanks, @varmanishant!

One thing to consider: some of what you may wish to save is not persisted in the container as such. For example the IDE workbench layout, including currently opened editors, is saved in the client’s local web storage (i.e. the browser used to access the Theia backend running in the container).

[John Kapolos]

@marc-dumais When I destroy and recreate the docker container (nightly build), the local web cache is reset* and everything re-initialises. I did use a volume for ~/.theia but it’s always empty. Is this a bug (or a feature :slight_smile: )?

*Steps:

  • Launch container

  • Change theme

  • Destroy container

  • Launch again

  • Refresh the web page: theme gone

Is it possible to preserve the settings by using a docker volume or some configuration flag?

Hi @kapolos . One pitfall to using docker volumes is that the user on the host generally will not match the user in the container, which often causes permission issues. That might explain the result you get above. Another thing: depending on which Theia image you’re using, the default user in the container might be “theia” or “root”, so you would need to mount the docker volume under the correct user’s home.

I gave this a try and it seemed to work for me:

$> mkdir /tmp/.theia
$> chmod 777 /tmp/.theia
$> docker run -it -p 3000:3000 -v "/tmp/.theia:/home/theia/.theia" theiaide/theia:latest

Access the Theia app with my browser (localhost:3000) and swithed to theme “red”.
Kill the docker container and close browser tab, start a new container and connect to it in a new tab

Result: Theme “red” is used.

[John Kapolos]

@marc-dumais Thank you very much! :beers: With your example, I realised my mistake: I was using the wrong path in the volume mount :expressionless: (/home/.theia instead of /home/theia/.theia)