correctly preserve the host user's uid
This commit is contained in:
parent
28f14b82b0
commit
8185ab8876
10
otherworld
Executable file → Normal file
10
otherworld
Executable file → Normal file
@ -45,8 +45,11 @@ def docker_create (image, container, options, command):
|
|||||||
def docker_get_user (container, user):
|
def docker_get_user (container, user):
|
||||||
return check_output(["docker", "exec", container, "groups", user])
|
return check_output(["docker", "exec", container, "groups", user])
|
||||||
|
|
||||||
def docker_create_user (container, user):
|
def docker_create_user (container, user, uid=None):
|
||||||
call(["docker", "exec", container, "adduser", user, "--gecos", ",,,", "--disabled-password"])
|
command = ["docker", "exec", container, "adduser", user, "--gecos", ",,,", "--disabled-password"]
|
||||||
|
if uid is not None:
|
||||||
|
command = command + ["--uid", str(uid)]
|
||||||
|
call(command)
|
||||||
call(["docker", "exec", container, "chown", user, f"/home/{user}"])
|
call(["docker", "exec", container, "chown", user, f"/home/{user}"])
|
||||||
|
|
||||||
def docker_start (container):
|
def docker_start (container):
|
||||||
@ -95,6 +98,7 @@ def expand_user_volumes (volumes):
|
|||||||
return mappings
|
return mappings
|
||||||
|
|
||||||
user = os.environ["USER"]
|
user = os.environ["USER"]
|
||||||
|
uid = int(check_output(["id", "-u"]).strip())
|
||||||
image_name = os.environ.get("OW_IMAGE", IMAGE_NAME)
|
image_name = os.environ.get("OW_IMAGE", IMAGE_NAME)
|
||||||
container_name = os.environ.get("OW_CONTAINER", f"{CONTAINER_NAME}_{user}")
|
container_name = os.environ.get("OW_CONTAINER", f"{CONTAINER_NAME}_{user}")
|
||||||
build_path = None
|
build_path = None
|
||||||
@ -170,7 +174,7 @@ try:
|
|||||||
except Exception:
|
except Exception:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f">> Creating container user: {user}")
|
print(f">> Creating container user: {user}")
|
||||||
docker_create_user(container_name, user)
|
docker_create_user(container_name, user, uid)
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(f">> Welcome to {container_name} (IP {container['NetworkSettings']['IPAddress']})")
|
print(f">> Welcome to {container_name} (IP {container['NetworkSettings']['IPAddress']})")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user