Hello! I am not being able to create a bind mount so all of my containers can save here and also access it, as well as outside of docker. I have tried different ways to create it but when I run my containers, nothing is being saved in the location I want.
The location is ‘storage-spooler’, this folder is inside another folder where I have my docker-compose.yml since I have read that it has to be in the same location as the .yml (if not please let me know so I can move it one folder outside )
Docker compose:
version: '3.8'
x-resource-limits: &resource-limits
deploy:
resources:
limits:
memory: ${MAX_RAM}
cpus : ${MAX_CPU}
# reservations:
services:
main_service:
build:
context: ../
dockerfile: ./service_containers/main_service/Dockerfile
stop_grace_period: 50s
restart: always
stdin_open: true
tty: true
network_mode: "host"
volumes:
# - ./storage-spooler:${PATH_TO_STORAGE_SPOOLER}
- ./storage-spooler:/home/y3qucfm/workspace/ods/system_controller/storage-spooler
env_file:
- ./.env
<<: *resource-limits
can_logger_service:
build:
context: ../
dockerfile: ./service_containers/can_logger_service/Dockerfile
network_mode: "host"
stop_grace_period: 50s
restart: always
stdin_open: true
tty: true
volumes:
# - ./storage-spooler:${PATH_TO_STORAGE_SPOOLER}
- ./storage-spooler:/home/y3qucfm/workspace/ods/system_controller/storage-spooler
env_file:
- ./.env
<<: *resource-limits
monitor_data_service:
build:
context: ../
dockerfile: ./service_containers/monitor_data_service/Dockerfile
network_mode: "host"
restart: always
stop_grace_period: 50s
stdin_open: true
tty: true
volumes:
# - ./storage-spooler:${PATH_TO_STORAGE_SPOOLER}
- ./storage-spooler:/home/y3qucfm/workspace/ods/system_controller/storage-spooler
env_file:
- ./.env
<<: *resource-limits
I am creating a file in my can_logger_service ( outside the folder where I have my .yml → ./service_containers/can_logger_service) container with a python script:
self.log_file = open(f'{self.path_to_spooler}/log_file.asc', 'w')
print(f"File opened: {self.log_file}")
where my path_to_storage_spooler is a .env variable:
PATH_TO_STORAGE_SPOOLER=/home/y3qucfm/workspace/ods/system_controller/storage-spooler
To resume everything, I want to be able to stare my files in the “storage-spooler” inside system_controllers. My docker-compose.yml gets the dockerfiles the folders in ./service_containers
I have tried to modify in lots of ways my docker compose but nothing seems to be working! please help! thank you!