The short answer to the “How to keep it unchanged” question is “Don’t run the container in privileged mode”
Of course this short answer will not help you. But I feel I have an idea only because I had a similar issue before, and I believe I know what you mean by “virtual screen”.
First of all, the privileged mode allows the container to do basically anything on the host. If you run systemd in a privileged container without proper configuration to optimize it for Docker, your GUI can restart.
Without knowing what your container does (because I don’t know much about ROS), it remains a guess, but if running the container affects the desktop environment on the host, the application might not suitable to run in a container. If it is, you need to find a configuration for the app that works. For example, systemd can run in containers, although it is different on each Linux distribution but one common requirement is to set the “ENV container=docker” environment variable.
The official ubuntu image doesn’t have systemd so if you ran it somehow, it was installed as a dependency due to a wrong attempt to install ROS2 and the SDK.
Thanks for your comment.
This is a full command
$docker run -it -d --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name docker-20.04 -p 3579:22 -h docker-ubuntu -u root ubuntu:20.04-base-v1.1 /sbin/init
You are right. systemd restart ubunut GUI.
This is full command
$docker run -it -d --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name docker-20.04 -p 3579:22 -h docker-ubuntu -u root ubuntu:20.04-base-v1.1 /sbin/init
I change like this
docker run -it -d --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro --name docker-20.04 -p 3579:22 -h docker-ubuntu -u root ubuntu:20.04-base-v1.1 /usr/bin/bash
and then, virtual console is not changed…
Is there any method to use “systemd” without changing vitual console?
I don’t recommend using systemd in a Docker container. When you try that, it usually means you don’t follow the recommended installation process of an application to run in a container. I have to quote my previous question which you forgot to reply:
If you want to read what I learned about systemd and Docker two years ago, you can find it here: