简体   繁体   中英

Docker route traffic through vpn

I am trying to dockerize my existing application which is having the following stack

  • Python (Flask)
  • Microsoft SQL server
  • Celery
  • Redis

Following are the relevant files

Dockerfile

FROM python:3.7
WORKDIR /opt/myapp

COPY myapp .
RUN pip install flask
RUN pip install --no-cache -r requirements/requirements.txt

docker-compose.yml *

version: "3"

services:
  web:
    build: .
    command: python run.py
    ports:
      - "5000:5000"

SQL server is not running as a docker container and it requires a VPN connection. Connection is being made from the code files itself. How can i connect to a non dockerized MS SQL running on some other server (need to be accessed with VPN) with dockerized application.

The simplest way, especially for development is to use Docker's host networking mode :

docker run --network host [image]

This bypasses Docker's network isolation and will use the underlying host routing for the container.

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