useruser00
useruser00

Reputation: 189

Access Host folder path from Docker Container which runs C# Windows Application

I have multiple containers which run windows console applications in centOS, which create report files and i can access the output files in host server via volumes specified in docker-compose.yml

report_output:
    image: report:latest
    ports: ["80:80"]
    container_name: profit_report
    restart: always
    volumes:
     - /home/profit_report/:/app/report_output

I am writing another C# console application delete_report which deletes reports older than 2 years. If I add C# code to access path /home/profit_report/ in the new console, will it be able to access the path from the inside container "delete_report"?

Or how can i access the path /app/report_output of report_output container from delete_report container to delete the files directly inside the container.

Is connecting to host server path from container efficient way of doing this or is it efficient connecting to required container and access path inside?

All of the containers are binded in same network.

Upvotes: 0

Views: 1436

Answers (1)

Dmitriy Korolev
Dmitriy Korolev

Reputation: 288

The compose config:

volumes:
     - /home/profit_report/:/app/report_output

Tells us, that folder

/home/profit_report

will be mounted in container(s), it means that any manipulation in it, also applied in container(s) with this mount, because it is just a mounting.

Therefore, you can create another container with same mounting and manipulate the files as you want.

So you delete report app, can be containered with mount like this:

volumes:
         - /home/profit_report/:/app/report_to_delete (or any path that you want)

And inside this container you just need to get files from mount path (/app/report_to_delete)

Upvotes: 1

Related Questions