Hi,
we are running a C++ application on a verdin board in a docker container
and I currently try to implement the logging feature for the c++ application.
I have the following docker-compose
version: "3.9"
services:
servicename-debug:
build:
context: .
dockerfile: Dockerfile.debug
volumes:
- type: bind
source: ./logs
target: /tmp/logs
image: ${LOCAL_REGISTRY}:5002/servicename-debug:${TAG}
privileged: true
ports:
- 6502:6502
I assumed that, this should create a folder inside the docker container called /tmp/logs which is mapped to the TorizonCore folder ./logs.
So, the logs should persist a restart.
But the problem is fopen_s() always returns error 13 (permission denied)! (mode=“a”, Creates the file if it doesn’t exist.)
So I assume the docker container does not have the rights to create a file in a TorizonCore folder.
How can this be fixed?
The user permissions for the tmp folder on TorizonCore are drwxrwxrwt
The user permissions in the docker container:
The Hard/Software is:
Software summary
------------------------------------------------------------
Bootloader: U-Boot
Kernel version: 5.15.129-6.4.0+git.67c3153d20ff #1-TorizonCore SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023
Kernel command line: root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/460c0c1dde52ce6a4fd14e6ff7399ad1c879175a9ffa047acbb97523d9376591/0
Distro name: NAME="TorizonCore"
Distro version: VERSION_ID=6.4.0-build.5
Hostname: verdin-imx8mp-xxxxxxxx
------------------------------------------------------------
Hardware info
------------------------------------------------------------
HW model: Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version: 0058 V1.0D
Serial number: xxxxxxxx
Processor arch: aarch64
------------------------------------------------------------
To reproduce the problem just create a python project in vscode with the following main.py
#!python3
def run():
file_path = "/tmp/new_file.txt"
# Open the file in append mode
try:
with open(file_path, 'a+') as file:
file.seek(0)
num_lines = len(file.readlines())
# Write content to the file
file.write("The application started the {} time.\n".format(num_lines + 1))
print(f"File '{file_path}' created successfully and text added.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
run()
Debug python local → everything works
Debug Torizon ARMv8 → error 13 (Permission denied)
To the docker-compose.yml I just added
How can this be fixed ???
I think it is currently not possible to save persistent data on the host if using the docker environment.