Docker Community Forums

Share and learn in the Docker community.

How to configure containers to get access to them using VPN?

Hi,
I have simple docker-compose.yml with apache server and openvpn.

version: '2'
services:

  apache:
    image: 'bitnami/apache:latest'
    ports:
      - '1889:8080'
      - '443:8443'
    volumes:
      - ./mysite:/app

  openvpn:
    cap_add:
      - NET_ADMIN
    image: kylemanna/openvpn
    container_name: openvpn
    ports:
      - "1194:1194/udp"
    restart: always
    volumes:
      - ./openvpn-data/conf:/etc/openvpn

After configured kylemanna/openvpn I can connect to VPN from host but how to make Apache available through VPN?

  1. which kind of vpn would you like to use?

  2. you need connection from the container, or from the hosts?
    Adding another container do not permit apache to be connected because the network are different.
    Better solutions could be add some posix capability to the openvpn container:

    sysctls:

    • “net.ipv4.conf.all.rp_filter=2”
      cap_add:
    • net_admin
    • sys_module

you should route the traffic from apache to openvpn container.
tell me if the solutions could be fit for you.