--network host所有容器和主机互通
docker run -it --privileged=true --network=host ubuntu:20.04 /bin/bash
root@A1022:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [876 kB]
可以愉快的安装软件了
该博客介绍了如何通过`docker run`命令以主机网络模式启动一个Ubuntu容器,并在其中执行`apt-get update`来愉快地安装软件。这个过程涉及到`--network=host`和`--privileged=true`参数的使用,使得容器能够与主机网络互通。

2132

被折叠的 条评论
为什么被折叠?



