We have two docker containers. The first container is backend_device_service which we access using the command -> docker exec -it backend_device_service bash.
On this backend_device_container we write our python code. Now I am writing an API which needs to access a file which is on another container rsyslog (server is same just the container is different).
We access this container using the command -> docker exec -it rsyslog bash
In this container at the path -> /var/log/CPE my file contains which I need to access.
However I can access any path in the same container using the following piece of code:-
class SysLogReader(APIView):
authentication_classes = [JWTAuthentication]
permission_classes = [IsAuthenticated]
def get(self, request):
content = os.popen('cat /app/sdwan_device_service/devices/views').read().strip('\n').lower()
logger.info(f"\ncontent of the file:\n {content}\n")
dir_path = os.path.dirname(os.path.realpath(__file__))
resp = {"success":True, "message" : f"Directoty path is {dir_path}"}
return Response(resp, status=status.HTTP_200_OK)
While my problem is how to access the file which is in another container rsyslog.