containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.59k stars 219 forks source link

Start toolbox at boot to prevent delay when executing command #1559

Closed thepragmaticmero closed 1 month ago

thepragmaticmero commented 1 month ago

Is your feature request related to a problem? Please describe. Every time I reboot my computer, and execute a toolbox enter command. There's an annoying delay I have to sit through before entering my container. My objective is to remove that delay by keeping the container started at boot or instantly after boot using a systemd service (lazy loading prefferably, what I mean by this is not making the boot process to my Desktop Environment longer). I wanted to keep it straight forward using a podman generate systemd command. But the cli advised me that the command was deprecated, podman advised that I use podman Quadlets. But then I discovered that a toolbox command is a little bit more complex than average podman run command. I needed to use a LLM (Claude.ai) to get the complete command just to try and run a podman equivalent command to toolbox. It's a little too much to ask for a user I think.

Podman run equivalent command to toolbox (misinformation sorry)

podman run \
  --name fedora-toolbox-41 \
  --hostname toolbox \
  --privileged \
  --security-opt label=disable \
  --user 1000:1000 \
  -e SHELL=/bin/bash \
  -e HOME=/var/home/user \
  -v /var/home/senati:/var/home/user:rslave \
  -v /home/senati:/home/user:rslave \
  -v /media:/media:rslave \
  -v /mnt:/mnt:rslave \
  -v /run/media:/run/media:rslave \
  -v /etc/hosts:/etc/hosts:ro \
  -v /etc/resolv.conf:/etc/resolv.conf:ro \
  -v /tmp:/tmp:rslave \
  --pid=host \
  --ipc=host \
  --network=host \
  localhost/fedora-toolbox:41 \
  /bin/bash

Describe the solution you'd like toolbox quadlet fedora-toolbox-41 or toolbox at-boot fedora-toolbox-41 Just for simplicity's sake.

Describe alternatives you've considered I've tried the deprecated podman generate command and trying to use cockpit-podman, the later doesn't have a "start at boot" option.

debarshiray commented 1 month ago

Toolbx 0.0.99.6 has optimized the the toolbox enter and run commands due to this issue. Does that make it fast enough for you?

The toolbox enter and run commands don't use podman run directly. They use podman start and podman exec separately. The podman start part is just that - look for podman.Start in the code. It's the podman exec invocation that has all the funky options.

I suspect that it's the podman start that is slow when you are using a container for the first time, because the container's entry point does varies things to configure the container appropriately.

thepragmaticmero commented 1 month ago

The toolbox enter and run commands don't use podman run directly.

Sorry for spreading misinformation Q-Q.

I suspect that it's the podman start that is slow when you are using a container for the first time

Exactly! Well, at least the wait was a little too long for my liking on Fedora Silverblue 40. On Fedora Silverblue 41 (toolbox --version -> 0.0.99.6, now it's acceptably quick. By the time I finish typing after running toolbox enter , the container has already loaded, which is nice and neat. At least on my beefy computer (5800x + NVMe SSD), it's no problem. Thanks for the fix.

debarshiray commented 1 month ago

Duplicate of https://github.com/containers/toolbox/issues/1070

debarshiray commented 1 month ago

I suspect that it's the podman start that is slow when you are using a container for the first time

Exactly! Well, at least the wait was a little too long for my liking on Fedora Silverblue 40. On Fedora Silverblue 41 (toolbox --version -> 0.0.99.6, now it's acceptably quick. By the time I finish typing after running toolbox enter , the container has already loaded, which is nice and neat. At least on my beefy computer (5800x + NVMe SSD), it's no problem. Thanks for the fix.

I am glad to hear that. Thanks for the confirmation!