File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,18 @@ def install_environment(
7373 os .mkdir (directory )
7474
7575
76+ def get_docker_user (): # pragma: windows no cover
77+ try :
78+ return '{}:{}' .format (os .getuid (), os .getgid ())
79+ except AttributeError :
80+ return '1000:1000'
81+
82+
7683def docker_cmd (): # pragma: windows no cover
7784 return (
7885 'docker' , 'run' ,
7986 '--rm' ,
80- '-u' , '{}:{}' . format ( os . getuid (), os . getgid () ),
87+ '-u' , get_docker_user ( ),
8188 # https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
8289 # The `Z` option tells Docker to label the content with a private
8390 # unshared label. Only the current container can use a private volume.
Original file line number Diff line number Diff line change @@ -13,3 +13,14 @@ def test_docker_is_running_process_error():
1313 side_effect = CalledProcessError (* (None ,) * 4 ),
1414 ):
1515 assert docker .docker_is_running () is False
16+
17+
18+ def test_docker_fallback_user ():
19+ def invalid_attribute ():
20+ raise AttributeError
21+ with mock .patch .multiple (
22+ 'os' , create = True ,
23+ getuid = invalid_attribute ,
24+ getgid = invalid_attribute ,
25+ ):
26+ assert docker .get_docker_user () == '1000:1000'
You can’t perform that action at this time.
0 commit comments