Docker-compose在wsl上不能在容器中启动终止器



大家好,

我似乎有一个问题与docker-compose和wsl2在windows 10。我在ubuntu 20.04上运行docker,在windows 10上运行wsl2。由于某些原因,如果我使用以下命令运行docker映像:

sudo docker run --rm -it --network host -e DISPLAY -v ${HOME}/.config/terminator:/home/user1/.config/terminator -v /tmp/.X11-unix:/tmp/.X11-unix -v ${PWD}/.bashrc_local:/home/user1/.bashrc_local -e QT_X11_NO_MITSHM=1 --privileged hsp/ros2-bench-test:r1Sim2

Bash运行正常,我可以启动终结者和其他基于GUI的软件。

但是如果我使用docker-compose我得到这个错误:

sudo docker-compose up
Creating network "docker_compose_default" with the default driver
Creating terminator                       ... done
Creating docker_compose_yarp-ros2-image_1 ... done
Attaching to terminator, docker_compose_yarp-ros2-image_1
terminator         | 
terminator         | (terminator:20724): dbind-WARNING **: 07:58:24.948: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
terminator         | Unable to connect to DBUS Server, proceeding as standalone
terminator         | 
terminator         | ** (terminator:20724): WARNING **: 07:58:25.089: Binding '<Control><Alt>a' failed!
terminator         | Unable to bind hide_window key, another instance/window has it.
terminator         | Traceback (most recent call last):
terminator         |   File "/usr/bin/terminator", line 133, in <module>
terminator         |     TERMINATOR.layout_done()
terminator         |   File "/usr/lib/python3/dist-packages/terminatorlib/terminator.py", line 329, in layout_done
terminator         |     terminal.spawn_child()
terminator         |   File "/usr/lib/python3/dist-packages/terminatorlib/terminal.py", line 1500, in spawn_child
terminator         |     result,  self.pid = self.vte.spawn_sync(Vte.PtyFlags.DEFAULT,
terminator         | gi.repository.GLib.GError: g-io-error-quark: Failed to execute child process “/bin/bash”: Failed to fdwalk: Operation not permitted (14)
terminator exited with code 1
docker_compose_yarp-ros2-image_1 exited with code 0

docker-compose如下:

version: "3.7"
x-base: &base
image: hsp/ros2-bench-test:r1Sim2
environment:
- DISPLAY=${DISPLAY}
- XAUTHORITY=/home/user1/.Xauthority
- QT_X11_NO_MITSHM=1
- LIBGL_ALWAYS_INDIRECT=0
- YARP_COLORED_OUTPUT=1
volumes:
- "/tmp/.X11-unix:/tmp/.X11-unix:rw"
- "/etc/hosts:/etc/hosts"
- "/home/elandini/.gitconfig:/home/user1/.gitconfig"
- ".bashrc_local:/home/user1/.bashrc_local"
- "/home/elandini/.config/terminator:/home/user1/.config/terminator"
network_mode: host
ipc: host
pid: host
security_opt:
- apparmor:unconfined

services:
# Images
yarp-ros2-image:
image: hsp/ros2-bench-test:r1Sim2
build:
dockerfile: Dockerfile
target: ros2CtrlDefault
context: .

terminator:
<<: *base
container_name: terminator
command: terminator -g /home/user1/.config/terminator/config

我在docker-compose中看不到错误。但是我对docker-compose很陌生,所以它可能真的很微不足道。

编辑

感谢ste93的回答。有了privileged: true,一切都行得通。

有没有人知道一种方法来避免给容器特权,仍然使这个工作?

如果你把privileged: true放在docker组合中,它应该可以工作。

最新更新