简体   繁体   English

使用 WSL2 时如何为 docker for windows 运行 iptables 命令

[英]How to run an iptables command for docker for windows when using WSL2

I am running Ubuntu 20.04 on WSL 2 along with docker desktop (2.3.0.5) for Windows.我在 WSL 2 上运行 Ubuntu 20.04 以及 Windows 的 docker 桌面(2.3.0.5)。

Docker desktop has been setup so that I can access the docker daemon from my Ubuntu shell. Docker 桌面已经设置好,所以我可以从我的 Ubuntu shell 访问 docker 守护进程。

I would like to run the command (see this question for motivation for running the command):我想运行该命令(有关运行该命令的动机,请参阅此问题):

sudo iptables -I DOCKER-USER -j DROP

but when I do I get the error: iptables: No chain/target/match by that name.但是当我这样做时,我收到错误: iptables: No chain/target/match by that name.

According to the docker documentation : "Docker installs two custom iptables chains named DOCKER-USER and DOCKER, and it ensures that incoming packets are always checked by these two chains first."根据 docker文档:“Docker 安装了两个名为 DOCKER-USER 和 DOCKER 的自定义 iptables 链,它确保传入的数据包始终首先由这两个链检查。”

How can I apply this iptable rule to the docker desktop installation on windows?如何将此 iptable 规则应用于 Windows 上的 docker 桌面安装?

The documentation specifies that it's a feature for a Linux environment.该文档指定它是 Linux 环境的一项功能。

On Linux, Docker manipulates iptables rules to provide network isolation.在 Linux 上,Docker 操纵 iptables 规则来提供网络隔离。

Have you tried using iptables within WSL2 itself?您是否尝试过在 WSL2 中使用 iptables? If you're using Docker desktop with the WSL2 Ubuntu integration, it might work.如果您将 Docker 桌面与 WSL2 Ubuntu 集成一起使用,它可能会工作。

暂无
暂无

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

相关问题 在 WSL2 上使用 Docker 桌面和 Windows 10 主页时,如何更改 docker 图像的位置? - How can I change the location of docker images when using Docker Desktop on WSL2 with Windows 10 Home? 尝试使用带有 wsl2 的 docker 在本地运行 lambda 时出错 - error when trying to run lambda locally using docker with wsl2 “sudo systemctl enable docker”不可用:在 WSL2 上启动时自动运行 Docker(使用“sysvinit”/“init”命令或解决方法) - "sudo systemctl enable docker" not available: Automatically run Docker at boot on WSL2 (using a "sysvinit" / "init" command or a workaround) 无法在 Windows11 上运行 docker 4.14.1 WSL2 - Cannot run docker 4.14.1 WSL2 on Windows11 In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver? - In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver? 无法使用新的 Windows 终端在 WSL2 中启动 Docker - Unable to start Docker in WSL2 using new Windows Terminal 如何从 windows 到达并检查 docker 引擎是否在 wsl2 中运行 - How to reach and check if docker engine is running in wsl2 from windows 使用 Docker Desktop 和 WSL2 时,我的卷安装在哪里? - Where are my volumes mounted when using Docker Desktop and WSL2? 使用 Docker 和 WSL2 在 VSCode 中调试 PHP 时出现问题 - Issues when Debugging PHP in VSCode using Docker and WSL2 在wsl2上同步windows和docker太慢了 - Synchronize windows and docker on wsl2 is too slow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM