@@ -680,6 +680,15 @@ def _omc_port_get(self) -> str:
680680
681681 return port
682682
683+ @staticmethod
684+ def _getuid () -> int :
685+ """
686+ The uid to give to docker.
687+ On Windows, volumes are mapped with all files are chmod ugo+rwx,
688+ so uid does not matter as long as it is not the root user.
689+ """
690+ return 1000 if sys .platform == 'win32' else os .getuid ()
691+
683692 def get_server_address (self ) -> Optional [str ]:
684693 if self ._dockerNetwork == "separate" and isinstance (self ._dockerCid , str ):
685694 output = subprocess .check_output (["docker" , "inspect" , self ._dockerCid ]).decode ().strip ()
@@ -781,6 +790,7 @@ def _docker_omc_cmd(
781790 "docker" , "run" ,
782791 "--cidfile" , docker_cid_file .as_posix (),
783792 "--rm" ,
793+ "--user" , str (self ._getuid ()),
784794 ]
785795 + self ._dockerExtraArgs
786796 + dockerNetworkStr
@@ -887,7 +897,10 @@ def _docker_omc_cmd(self, omc_path_and_args_list) -> list:
887897 if isinstance (self ._interactivePort , int ):
888898 extraFlags = extraFlags + [f"--interactivePort={ int (self ._interactivePort )} " ]
889899
890- omc_command = (["docker" , "exec" ]
900+ omc_command = ([
901+ "docker" , "exec" ,
902+ "--user" , str (self ._getuid ()),
903+ ]
891904 + self ._dockerExtraArgs
892905 + [self ._dockerCid , self ._dockerOpenModelicaPath ]
893906 + omc_path_and_args_list
0 commit comments