繁体   English   中英

wsl 上的 Docker-compose 无法在容器中启动终结器

[英]Docker-compose on wsl cannot start terminator in container

祝大家有美好的一天,

我似乎在 windows 10 上遇到了 docker-compose 和 wsl2 的问题。我在 windows 10 上的 wsl2 中的 ubuntu 20.04 上运行 docker。由于某种原因,如果我使用以下命令运行 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.yaml 文件中看不到错误,但我对 docker-compose 还是很陌生,所以它可能真的很微不足道。

编辑

感谢ste93回答 privileged: true一切正常。

有没有人知道一种方法可以避免授予容器特权并且仍然可以进行这项工作?

如果您将privileged: true放在 docker compose 中,它应该可以工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM