Hi @balena, My dockerfile is working very well and the processed images are saved into the ‘outputs’ folder in the container running on the Nvidia Jetson integrated with Balena cloud. However, I am not able to save these images outside of the container. The below is my docker-compose file. I used ‘volumes’ but it seems not working.
version: '2'
volumes:
edge-data:
services:
rapid_edge:
restart: always
build: .
network_mode: host
privileged: true
environment:
- UDEV=1
devices:
- "/dev:/dev"
volumes:
- 'edge-data:/outputs'
More specifically, I am saving the processed images at the end of a python script in my app dockerized in the container. For this, I am using the below line having opencv library write function to save the processed images.
...
cv2.imwrite('./outputs/frame_%d.jpg' % count, np_img, [cv2.IMWRITE_JPEG_QUALITY, 100])
print('Saved image', count)
count += 1
...
I am getting ‘Saved image …’ print output and the files are saved into ‘output’ folder in the container but not into the out of the container. I checked everywhere Host OS of the device including var/lib/docker/volumes but nothing was saved there.
Am I missing anything?
Hi,
on a quick check I’d say that the file path is pointing to the local path of the python execution context: ‘./outputs/frame_%d.jpg’.
In your docker-compose file you specify that the volume will be mounted to /output
inside the running container (absolute path and without ‘s’)
Please try if changing to ‘/output/frame_%d.jpg’ fixes the issue.
For details I’m linking you the Balena documentation here: Communicate outside the container - Balena Documentation
Best Regards
Harald
Hi @fisehara, thanks a lot for a quick reply. I recognized that I miswrote ‘volumes’ part of docker-compose file in the forum. I fixed it on the post just now. Sorry for the confusion. Can you please look at it again to provide you with the accurate one?
I can say that there is no mismatch between the path in volume and the path in cv2.imwrite.
By the way, I saw the document you sent me before. For this, I can say that it seems my code follows it.
Do you have any else ideas?
@aktaseren the path is still wrong in your code, in your code you are using ./outputs
, but you really want to write to /outputs
(remove the .
)
Guys thanks for the help. There was no issue with the paths in my python scripts. They are able to run without docker and now with docker. I made a silly mistake on docker-compose file that I recognized now. I should have coded mounting the volume in docker-compose as follows:
volumes:
- 'edge-data:/app/outputs'
‘app’ is actually the main folder of my project that I containerize. In docker-compose file, I expected that I was already in the container and no need to add the main folder name at the start of the path. Now, adding ‘app’ solved this silly mistake.