在 Docker 容器内开发时,在 Visual Studio 代码中设置默认键盘时遇到问题

在 Docker 容器内开发时,在 Visual Studio 代码中设置默认键盘时遇到问题

我无法跟上本指南在 Ubuntu 18.04 上使用特定存储库时(如果有人想跟进,存储库是这里)。当我尝试按照以下步骤操作时:

从出现的命令列表中选择 Remote-Containers: Open Folder in Container...,然后打开刚刚克隆的项目的根文件夹。

我遇到一个问题,Visual Studio 代码要求我“选择这台机器的键盘布局”。 如下所示:

...
[62625 ms] Setting up netbase (5.4) ...
[62645 ms] Setting up libwebp6:amd64 (0.5.2-1) ...
[62654 ms] Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-5) ...
[62664 ms] Setting up libdb-dev:amd64 (5.3.1) ...
[62673 ms] Setting up libjsoncpp1:amd64 (1.7.4-3) ...
[62682 ms] Setting up libvorbisfile3:amd64 (1.3.5-4+deb9u2) ...
[62691 ms] Setting up libedit2:amd64 (3.1-20160903-3) ...
[62701 ms] Setting up libgmp-dev:amd64 (2:6.1.2+dfsg-1) ...
[62710 ms] Setting up libx265-95:amd64 (2.1-2+b2) ...
[62719 ms] Setting up keyboard-configuration (1.164) ...
[62790 ms] debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
[63090 ms] Configuring keyboard-configuration
----------------------------------

Please select the layout matching the keyboard for this machine.

[63090 ms]   1. English (US)
  2. English (US) - Cherokee
  3. English (US) - English (Colemak)
  4. English (US) - English (Dvorak alternative international no dead keys)
  5. English (US) - English (Dvorak)
[63091 ms]   6. English (US) - English (Dvorak, international with dead keys)
[63091 ms]   7. English (US) - English (Macintosh)
  8. English (US) - English (Programmer Dvorak)
[63091 ms]   9. English (US) - English (US, alternative international)
  10. English (US) - English (US, international with dead keys)
  11. English (US) - English (US, with euro on 5)
[63091 ms]   12. English (US) - English (Workman)
  13. English (US) - English (Workman, international with dead keys)
[63091 ms]   14. English (US) - English (classic Dvorak)
[63091 ms]   15. English (US) - English (international AltGr dead keys)
[63091 ms]   16. English (US) - English (left handed Dvorak)
[63091 ms]   17. English (US) - English (right handed Dvorak)
  18. English (US) - English (the divide/multiply keys toggle the layout)
  19. English (US) - Russian (US, phonetic)
  20. English (US) - Serbo-Croatian (US)
[63091 ms]   21. Other
[63092 ms] Keyboard layout: 

但是我无法在 VS Code 的终端中实际输入以选择键盘?我在这里找到了其他几个对此的回应,您可以在 dockerfile 中执行类似这样的操作:DEBIAN_FRONTEND=noninteractive apt-get install keyboard-configuration但这似乎也无法解决问题。我已经在 Macbook 上尝试了整个过程,只是为了确保这不仅仅是我的问题,而且它可以顺利通过这一步,这让我认为这是一个与 Ubuntu 相关的问题(或者至少是 Ubuntu 上的 vs code 问题),但我有点不知道如何解决这个问题。

您可以在此处查看 dockerfile(如果有帮助的话):

FROM debian:stretch-slim

#
# avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

ARG USERNAME=neko
ARG USER_UID=1000
ARG USER_GID=$USER_UID

#
# install neko dependencies
RUN set -eux; apt-get update; \
    apt-get install -y --no-install-recommends wget ca-certificates pulseaudio openbox dbus-x11 xserver-xorg-video-dummy supervisor; \
    apt-get install -y --no-install-recommends libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx4; \
    #
    # create a non-root user
    groupadd --gid $USER_GID $USERNAME; \
    useradd --uid $USER_UID --gid $USERNAME --shell /bin/bash --create-home $USERNAME; \
    adduser $USERNAME audio; \
    adduser $USERNAME video; \
    adduser $USERNAME pulse; \
    #
    # setup pulseaudio
    mkdir -p /home/$USERNAME/.config/pulse/; \
    echo "default-server=unix:/tmp/pulseaudio.socket" > /home/$USERNAME/.config/pulse/client.conf; \
    #
    # workaround for an X11 problem: http://blog.tigerteufel.de/?p=476
    mkdir /tmp/.X11-unix; chmod 1777 /tmp/.X11-unix; chown $USERNAME /tmp/.X11-unix/; \
    #
    # make directories for neko
    mkdir -p /etc/neko /var/www /var/log/neko; chmod 1777 /var/log/neko; chown $USERNAME /var/log/neko/;  \
    chown -R $USERNAME:$USERNAME /home/$USERNAME; \
    #
    # clean up
    apt-get clean -y; \
    rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#
# add gst to env
ENV PATH=/gst/local/bin:$PATH
ENV LD_LIBRARY_PATH=/gst/local/lib:$LD_LIBRARY_PATH
ENV PKG_CONFIG_PATH=/gst/local/lib/pkgconfig:$PKG_CONFIG_PATH

#
# copy gst
COPY .build/gst/local /gst/local/

#
# env
ENV USER=$USERNAME
ENV DISPLAY=:99.0

#
# copy configuation files
COPY .docker/files/dbus /usr/bin/dbus
COPY .docker/files/openbox.xml /etc/neko/openbox.xml
COPY .docker/files/neko/supervisord.conf /etc/neko/supervisord/neko.conf
COPY .docker/files/supervisord.conf /etc/neko/supervisord.conf
COPY .docker/files/xorg.conf /etc/neko/xorg.conf
COPY .docker/files/default.pa /etc/pulse/default.pa

#
# neko files
COPY client/dist/ /var/www
COPY server/bin/neko /usr/bin/neko

#
# neko env
ENV NEKO_PASSWORD=neko
ENV NEKO_ADMIN=admin
ENV NEKO_BIND=:8080

#
# run neko
CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"]

答案1

添加到 RUN/usr/sbin/dpkg-reconfigure keyboard-configuration/usr/bin/apt-get install -y --reinstall keyboard-configuration

localectl set-keymap en_US.UTF-8
systemctl restart keyboard-setup.service

尝试删除ENV DEBIAN_FRONTEND=noninteractive然后您应该能够输入。

也许考虑localectl set-keymap en_US.UTF-8一下systemctl restart keyboard-setup.service

答案2

您可以准备配置文件并将其移动到容器中(安装前执行)

COPY ./keyboard /etc/default/keyboard

配置文件如下所示:

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

这是一个较旧的版本,但我相信它会对你有用。有关详细信息,你可以在此处查看基础镜像-docker

相关内容