mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

How to make changes in container persistent? #311

Closed inifares23lab closed 3 years ago

inifares23lab commented 3 years ago

example: run: x11docker --desktop --gpu --sudouser --init=systemd x11docker/gnome inside container: apt install ... stop container

now when i re-run gnome image it starts from zero(which is not my intention). how do i solve that?

keep up the good work thank you

mviereck commented 3 years ago

To add packages, you need to build an image on your own. Example for a custom Dockerfile that adds firefox to x11docker/gnome:

FROM x11docker/gnome
RUN apt-get update
RUN apt-get install -y firefox

For storage of user configuration like e.g. desktop background use option --home. Please look at the docker documentation how to locally build images from a Dockerfile.

inifares23lab commented 3 years ago

hi, thanks for the quick response

so there is no way of doing it interactively inside the container right?

eine commented 3 years ago

so there is no way of doing it interactively inside the container right?

Run x11docker with option -i and command bash. That'll get you an interactive prompt were you can install whatever and start whichever GUI app.

eine commented 3 years ago

Remmber to use --user=0 or so, in order to be allowed to install tools inside the container.

mviereck commented 3 years ago

@inifares23lab It is possible to create a new image from a container with docker commit -t newimagename containername. Compare #288 and https://docs.docker.com/engine/reference/commandline/commit/

This way is discouraged because it generates unreproducible images. I recommend to adjust the Dockerfile instead. Option --sudouser is useful to try out intended changes first.

@eine With "interactively" he rather means how to change the image within a container instead of using the Dockerfile, not an interactive shell.

eine commented 3 years ago

@eine With "interactively" he rather means how to change the image within a container instead of using the Dockerfile, not an interactive shell.

@mviereck I believe we explained two parts of the same question. I explained how to run a container with x11docker and be able to install tools in there, which were not defined in the Dockerfile. You then explained how to save that running container as an image.

In any case, I agree that using a custom Dockerfile is the recommended solution. Using x11docker in interactive mode is only meant for interactively testing the specific set of packages that you need to add in the Dockerfile.