简体   繁体   English

WSL2 Ubuntu 20.04 无 output 用于 Docker 容器

[英]WSL2 Ubuntu 20.04 no output for Docker container

Issue问题

I'm on WSL2 Ubuntu 20.04, trying to run a Docker container in "interactive tty" mode, and I simply can't see the output of the container in the terminal.我在 WSL2 Ubuntu 20.04 上,试图在“交互式 tty”模式下运行 Docker 容器,我根本看不到终端中的 Z78E6221F6393D1356681DBCE39 容器。

Steps to reproduce重现步骤

  1. WSL2 terminal - Run a container and execute a command WSL2 终端 - 运行容器并执行命令
    $ docker run --rm -it alpine:3.12 # in container $ ls # hit enter, can't see anything
  2. WSL terminal - Scroll up and then down, suddenly the output appears WSL终端-上下滚动,突然出现output

I was able to overcome it with ttyd , but I prefer using my terminal, any leads on this one?我能够用ttyd克服它,但我更喜欢使用我的终端,这个有什么线索吗?

Things that I've tried我尝试过的事情

  1. Ubuntu 20.04 is my default distribution Ubuntu 20.04 是我的默认发行版
    PS C:\WINDOWS\system32> wsl --list --verbose NAME STATE VERSION * Ubuntu-20.04 Running 2 docker-desktop-data Running 2 docker-desktop Running 2
  2. Docker for Desktop > Settings > Resources > WSL Integration > Checked both Enable integration with my default WSL distro and Ubuntu-20.04 . Docker for Desktop > Settings > Resources > WSL Integration > 选中Enable integration with my default WSL distroUbuntu-20.04 I also unchecked, Applied & Restarted > Same results我也未选中,应用并重新启动>相同的结果
  3. Troubleshooting Windows Subsystem for Linux > OpenSSH-Server connection issuesLinux 的 Windows 子系统故障排除> OpenSSH 服务器连接问题
  4. PowerShell as Administrator > wsl --shutdown > Same results PowerShell 以管理员身份 > wsl --shutdown > 结果相同
  5. I can see the output of a container that prints something我可以看到打印某些东西的容器的 output
     $ docker run -it --rm unfor19/catfact:1.0 sh Cat fact: The first cartoon cat was Felix the Cat in 1919. In 1940, Tom and Jerry starred in the first theatrical cartoon “Puss Gets the Boot.” In 1981 Andrew Lloyd Weber created the musical Cats, based on TS Eliot's Old Possum's Book of Practical Cats

I guess it's related to the fact my $PATH variable was changed in my ~/.bashrc file.我想这与我的$PATH变量在我的~/.bashrc文件中更改的事实有关。

I was able to fix it by following the instructions in我能够按照中的说明进行修复

Adding the following line to my ~/.bashrc followed by wsl --shutdown fixed it将以下行添加到我的~/.bashrc后跟wsl --shutdown修复它

# Support Windows commands
export PATH="${PATH}:/mnt/c/Windows/system32"

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

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