Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help to do a patch to use systemctl/journalctl in docker VM ? #2026

Closed
Raizo62 opened this issue Jan 20, 2022 · 3 comments
Closed

help to do a patch to use systemctl/journalctl in docker VM ? #2026

Raizo62 opened this issue Jan 20, 2022 · 3 comments

Comments

@Raizo62
Copy link
Contributor

Raizo62 commented Jan 20, 2022

Hi

On LiveRaizo, i look to temporary transform the QEmu VM Debian in Docker VM.
so it will be lighter to use LiveRaizo in Virtualbox, for example.

But, in class room, i use often systemctl/journalctl to configure and debug service.
And, by default, systemctl doesn't work in docker.

To do it, the most easy method that i found is :

docker run --name centos.server -ti -d --privileged=true centos "/usr/sbin/init"
docker exec --tty --interactive centos.server /bin/bash

I have see that you afraid from risk here

I want to do a litlle patch on gns3 for LiveRaizo, but i didn't find the file where you are doing a "docker run" (the docker exec is in "gns3server/compute/docker/docker_vm.py")
Could you say the file or the function where i can add this : "--privileged=true" and "/sbin/init" ?
I hope that it is not more complicated.

@ghost
Copy link

ghost commented Jan 21, 2022

In GNS3 the docker images are already started with the option --privileged=true. The /usr/sbin/init command can be added as the "Start command" in the docker template.
docker_centos_systemd

As /usr/sbin/init shows only some output, the console won't give you a shell allowing to enter commands. But you can use the auxiliary console (right-click on the node -> Auxiliary console) to get a shell window.

If you have experience with systemd you might be able to add a systemd configuration, that starts a shell on /dev/pts/0, the console device of the docker node. Then you might be able to use the regular node console also for shell access. But I don't have systemd knowledge and can't help you with that.

@ghost
Copy link

ghost commented Jan 21, 2022

To answer your question about where to change the docker node creation (even though I don't think that's needed):

GNS3 uses the Docker API to interact with Docker, not the command line. The nodes creation is done in gns3server/compute/docker/docker_vm.py function create(). The params structure defines the default parameter for the docker node creation.

params = {
"Hostname": self._name,
"Name": self._name,
"Image": self._image,
"NetworkDisabled": True,
"Tty": True,
"OpenStdin": True,
"StdinOnce": False,
"HostConfig": {
"CapAdd": ["ALL"],
"Privileged": True,
"Binds": self._mount_binds(image_infos),
},
"Volumes": {},
"Env": ["container=docker"], # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573
"Cmd": [],
"Entrypoint": image_infos.get("Config", {"Entrypoint": []}).get("Entrypoint")
}

@Raizo62
Copy link
Contributor Author

Raizo62 commented Jan 21, 2022

Thank you @b-ehlers :-)

Your /usr/sbin/init in "Start command" works and asks me a login, then i doesn't need to use Auxiliary console :-)
I will investigate more

Thank you also for the Docker API information

@Raizo62 Raizo62 closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant