简体   繁体   中英

Access network in other docker container

I have two docker containers. The first has an OpenVPN server where multiple clients are connected. Now I want to reach one of the clients through the VPN from the other container (for example with a simple ping command). Is that possible?

At the moment I linked the containers this way:

version: '3'
services:

  app:
    build:
      context: .
      dockerfile: app.dockerfile
    links:
      - ovpn:ovpn

  ovpn:
    build:
      context: .
      dockerfile: ovpn.dockerfile
    working_dir: /etc/openvpn
    privileged: true
    volumes:
      - ./openvpn:/etc/openvpn
    ports:
      - 1194:1194/udp

I also tried it with the new networks key (docker compose version 3.5 ), but this also doesn't work.

I think that my approach is useless, because the link and network keys are only to make the containers themselves reachable. But I hope there is an other possibility.

Yes, it is possible. Theoretically, both containers are in the same network .

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