gpt4 book ai didi

linux - 在 LXD 容器中运行 Xvfb

转载 作者:太空宇宙 更新时间:2023-11-04 05:16:24 33 4
gpt4 key购买 nike

使用 Xvfb 可以轻松在 LXD 容器(ubuntu:16.04)内运行 GUI 应用程序并在容器内执行以下命令:

Xvfb -ac :99 -screen 0 1600x900x24 &
export DISPLAY=:99
firefox &

我的目标是在不登录的情况下执行上述命令,并在启动容器时自动执行(lxc start)。

我尝试在“/etc/init.d/my-script”中创建一个脚本,并使其可执行。但没机会,它不起作用( Link )。

此外,当我尝试执行 lxc exec <container_name> -- Xvfb -ac :99 -screen 0 1600x900x24 & 时在主机内部,它立即停止。

如果您分享您的解决方案,我将不胜感激。

最佳答案

您想要使用“nohup”运行 bash 命令,以便 bash 继续在后台运行。

示例:lxc exec 容器 -- nohup bash -c "Xvfb -ac :99 -screen 0 1600x900x24 &"

参见:https://www.cyberciti.biz/tips/nohup-execute-commands-after-you-exit-from-a-shell-prompt.html

关于linux - 在 LXD 容器中运行 Xvfb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48646846/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com