问题
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