[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH] tests/docker: add basic user mapping suppor
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [RFC PATCH] tests/docker: add basic user mapping support |
Date: |
Tue, 17 Jan 2017 19:34:34 +0800 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Tue, 01/17 11:19, Alex Bennée wrote:
> >> + if args.user:
> >> + uid = os.getuid()
> >> + uname = getpwuid(uid).pw_name
> >> + scriptlet = docker_dir+"/setup_user.sh"
> >> +
> >> + # write scriptlet
> >> + setup = open(scriptlet, "w")
> >> + setup.write("#!/bin/sh\n")
> >> + setup.write("useradd -u %d -U %s" % (uid, uname))
> >> + setup.close()
> >> +
> >> + st = os.stat(scriptlet)
> >> + os.chmod(scriptlet,
> >> + st.st_mode | stat.S_IXUSR | stat.S_IXGRP |
> >> stat.S_IXOTH)
> >
> > Is it cleaner we inject commands into the docker file directly?
>
> How do you mean? Running a second docker run command after we have built
> the image?
>
> IIRC I'd previously tried having a template approach where we took a
> docker.in and generated a final template for the build but we abandoned
> that approach.
build_image() generates a tmp_df, for "LABEL com.qemu..." (I should have named
it org.qemu.., really, it was a silly mistake). We can add an additional "RUN
useradd -u ..." line there just as well.
Fam
>
> >
> >> +
> >> dkr.build_image(tag, docker_dir, dockerfile,
> >> quiet=args.quiet, argv=argv)
> >>