我正在尝试使用以下脚本在 Windows 10 上的 Ubuntu 中安装 Docker,但随后我尝试将 Docker 作为服务运行 service docker start
Docker 没有启动,我在 docker.log 中发现错误。我在普通的 Ubuntu 机器上使用相同的安装说明,运行 docker 没有问题。
failed to start daemon: Error initializing network controller: Error creating default "bridge" network: Failed to Setup IP tables: Unable to enable NAT rule: (iptables failed: iptables --wait -t nat -I POSTROUTING -s 172.18.0.0/16 ! -o docker0 -j MASQUERADE: iptables: Invalid argument. Run `dmesg' for more information.
(exit status 1))
安装脚本
# 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
最佳答案
我遇到了同样的问题,这就是我发现的。
目前无法在 WSL 中运行 docker。解决方法是
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
echo "export DOCKER_HOST=localhost:2375" >> ~/.bash_profile
有了这个,我就可以在 WSL(ubuntu) 中运行 docker。希望能帮助到你。
信用:https://medium.com/@sebagomez/installing-the-docker-client-on-ubuntus-windows-subsystem-for-linux-612b392a44c4
关于docker - 在 Windows 10 上的 Ubuntu 中安装 Docker : Failed to Setup IP tables: Unable to enable NAT rule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61140111/