gpt4 book ai didi

docker - 无法从WSL连接到Docker

转载 作者:行者123 更新时间:2023-12-02 19:51:17 25 4
gpt4 key购买 nike

我已经在Windows的docker中检查了Expose the daemon on tcp...选项,现在正尝试从WSL连接。我已经运行了所有这些命令:

# Update the apt package list.
sudo apt-get update -y

# Install Docker's package dependencies.
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

# Download and add Docker's official public PGP key.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Verify the fingerprint.
sudo apt-key fingerprint 0EBFCD88

# Add the `stable` channel's Docker upstream repository.
#
# If you want to live on the edge, you can change "stable" below to "test" or
# "nightly". I highly recommend sticking with stable!
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

# Update the apt package list (for the new apt repo).
sudo apt-get update -y

# Install the latest version of Docker CE.
sudo apt-get install -y docker-ce

# Allow your user to access the Docker CLI without needing root access.
sudo usermod -aG docker $USER

echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc

但是, docker info仅给我:
Client:
Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
errors pretty printing info

可能是什么问题?我整天都在尝试。我正在运行WSL和Ubuntu 18.04,而不是WSL 2,因为如果没有内部构建,带来WSL 2的更新似乎不可用。

最佳答案

如果运行env | sort,会看到DOCKER_HOST=tcp://localhost:2375变量吗?如果不是,则可能需要运行source ~/.bashrc将新的环境变量加载到当前控制台中。

或者,启动一个新的终端实例。

另外,这似乎是一个愚蠢的问题,但我不得不问, docker 是否正确运行?从powershell中,如果您运行docker info,它是否会返回docker服务器的状态?

关于docker - 无法从WSL连接到Docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60555525/

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