简体   繁体   中英

Docker: how to access the hosts network with a docker container?

How can I access the hosts network with a docker container? Can I put a container in the hosts network with another IP from the hosts network?

Current situation:

  • Docker container (default bridge network): 172.17.0.2/16
  • Host (server): 10.0.0.2/24

Question:

  • Can I put the docker container on the 10.0.0.0/24 network as a secondary address? (or) Can I access the hosts network on the container and vica versa?

Reason:

  • I want to access the hosts network from my container (for example: monitoring server).
  • I want the container to act as a server accessible from the hosts network on all ports.

Note:

  • I run several docker containers so a few ports are already forwarded from the host and these should remain so. So an all-port-forward from the hosts IP isn't really a solution here.

Setup on host:

  • basic docker system
  • Centos 7

Macvlan networks may be the solution you are looking for. You could assign multiple MAC/IP addresses on virtual NICs over single physical NIC. There are some prerequisites for using Macvlan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM