You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for @bi-ran 's reply. You inspired me a lot. I know that I am not alone.
For now, I modify the script ai2bmd. In the container, a dummy user which has exactly the same uid and gid as the current user will be created. Thus the output files' permissions will belong to the current user.
#launch_cmd = f"docker run -w {docker_cwd} {cat(gpu_opts)} --rm {cat(mount_opts)} {_docker_image} python -u /ai2bmd/main.py {cat(argv)}"
#===========================================================================
import grp
"""
I add those lines to recover the file permissions,
from "root:root" to "{uid}:{gid}"
"""
uid = os.getuid()
uname = os.getlogin()
gid = os.getgid()
gname = grp.getgrgid(gid).gr_name
launch_cmd = f"docker run -w {docker_cwd} {cat(gpu_opts)} --rm {cat(mount_opts)} {_docker_image} sh -c \
'groupadd -g {gid} {gname} && useradd -u {uid} -g {gid} -m {uname} && su {uname} -c \
\"/opt/conda/bin/python -u /ai2bmd/main.py {cat(argv)}\"'" #===========================================================================
Maybe it's a better to generate a new container image with the current user created in advance. However, I am not familiar with docker, so I decide to use this modified script.
The file permission is 'root:root' instead of the current user.
I have searched online, but I didn't find a safe and easy solution.
The text was updated successfully, but these errors were encountered: