Hi,
I have a setup with VPN, details are given below:
Setup without docker:
Hardware <----> VPN Server <----> Laptop [Host Machine] (OpenVPN Client) (access data at “udp://:40000”)
My this setup works absolutely fine without any issues, I can access the data of my hardware in my python script after connecting OpenVPN client using my certificate files.
I am sending and receiving the data without any trouble.
Setup with docker:
Hardware <----> VPN Server <----> Laptop [Host Machine] <----> Docker Container <----> Python Script (“udp://:4000”) [Not working]
I tried to install the OpenVPN inside my container as part of my Dockerfile, but I don’t know how it works.
Any help will be appreciated.
Here is my dockerfile and Docker-compose file.
docker-compose.yml
services:
redis:
image: redis
container_name: redis
networks:
- dnetwork
app:
build: .
volumes:
- type: bind
#source: /home/mypython
target: /djangodir
ports:
- "8000:8000"
image: app:djangoimage
container_name: django_container
command: python manage.py runserver 0.0.0.0:8000
networks:
dnetwork:
ipv4_address: 192.168.0.31
celery-beat:
restart: always
build:
context: .
command: celery -A d beat -l INFO
volumes:
- type: bind
#source: /home/mypython
target: /djangodir
depends_on:
- redis
- app
networks:
zdnetwork:
ipv4_address: 192.168.0.33
celery-worker:
restart: always
build:
context: .
command: celery -A d worker -l INFO
volumes:
- type: bind
#source: /home/mypython
target: /djangodir
depends_on:
- redis
- app
- celery-beat
networks:
zdnetwork:
ipv4_address: 192.168.0.34
dockerfile
FROM python:3.8-slim-buster
ENV PYTHONUNBUFFERED=1
WORKDIR /djangodir
RUN apt-get update && apt-get upgrade -y && apt-get install cmake build-essential redis-server redis-tools net-tools ffmpeg openvpn -y
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]