2

I have this docker compose. I would like to route all traffic from app container through openvpn container without changing anything in host server. Is it possible?

version: '3'

services:
  openvpn:
    image: openvpn
    networks:
      - net

  app:
    image: myapp
    networks:
      - net

networks:
  net:
    driver: bridge
mmdc
  • 1,677
  • 3
  • 20
  • 32

1 Answers1

3

I found it by myself. I can add myapp to the same network of openvpn by adding a config to myapp service.

network_mode: "service:openvpn"

By this, I cannot expose the port on myapp but I can expose ports in openvpn to access myapp as they are in the same network

mmdc
  • 1,677
  • 3
  • 20
  • 32