Access network in other docker container

痞子三分冷 提交于 2021-02-11 13:50:42

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/52591578/access-network-in-other-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!