在线浏览思维导图

  • 入门

    Usage:  docker network COMMAND
    
    Manage networks
    
    Commands:
      connect     Connect a container to a network
      create      Create a network
      disconnect  Disconnect a container from a network
      inspect     Display detailed information on one or more networks
      ls          List networks
      prune       Remove all unused networks
      rm          Remove one or more networks
    
    Run 'docker network COMMAND --help' for more information on a command.
  • 命令

    • docker network ls 查看网络

      image-20230227162740724

    • docker network inspect networkName 查看网络详细信息

      image-20230227163220218

    • docker network rm networkName 删除网络

  • 网络模式

    • bridge 为每个容器分配一个docker0虚拟网络下的IP,虚拟网桥,默认为该模式;

      --network bridge

      docker network bridge

    • host 使用宿主机的IP和端口;

      --network host!

      docker network host

      宿主机ifconfig

      image-20230227173935456

      容器ifconfig

      image-20230227174003772

    • none 容器有独立的Network namespace,但是没有进行任何网络配置;

      --network none

      相当于禁用网络功能

    • container 和指定的容器共享IP、端口等;

      --network container:otherContainerID

      docker network container