[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/3] tests/docker: add basic user mapping sup
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/3] tests/docker: add basic user mapping support |
Date: |
Tue, 14 Feb 2017 23:20:25 +0800 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Tue, 02/14 15:11, Alex Bennée wrote:
>
> Fam Zheng <address@hidden> writes:
>
> > On Tue, 02/14 10:07, Alex Bennée wrote:
> >> Currently all docker builds are done by exporting a tarball to the
> >> docker container and running the build as the containers root user.
> >> Other use cases are possible however and it is possible to map a part
> >> of users file-system to the container. This is useful for example for
> >> doing cross-builds of arbitrary source trees. For this to work
> >> smoothly the container needs to have a user created that maps cleanly
> >> to the host system.
> >>
> >> This adds a -u option to the docker script so that:
> >>
> >> DEB_ARCH=armhf DEB_TYPE=stable ./tests/docker/docker.py build \
> >> -u --include-executable=arm-linux-user/qemu-arm \
> >> debian:armhf ./tests/docker/dockerfiles/debian-bootstrap.docker
> >>
> >> Will build a container that can then be run like:
> >>
> >> docker run --rm -it -v /home/alex/lsrc/qemu/risu.git/:/src \
> >> --user=alex:alex -w /src/ debian:armhf \
> >> sh -c "make clean && ./configure -s && make"
> >>
> >> Alternatively specifying USER will add the appropriate stanza when
> >> building via the Makefile:
> >>
> >> make docker-image-debian-armhf-cross USER=1
> >>
> >> Signed-off-by: Alex Bennée <address@hidden>
> >> Reviewed-by: Fam Zheng <address@hidden>
> >>
> >> ---
> >> v2
> >> - write the useradd directly
> >> - change long option to --add-current-user
> >> v3
> >> - images -> image's
> >> - add r-b
> >> - add USER to Makefile
> >> ---
> >> tests/docker/Makefile.include | 2 ++
> >> tests/docker/docker.py | 15 +++++++++++++--
> >> 2 files changed, 15 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> >> index 3f15d5aea8..8db55e43aa 100644
> >> --- a/tests/docker/Makefile.include
> >> +++ b/tests/docker/Makefile.include
> >> @@ -50,6 +50,7 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker
> >> $(call quiet-command,\
> >> $(SRC_PATH)/tests/docker/docker.py build qemu:$* $< \
> >> $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
> >> + $(if $(USER),--add-current-user,) \
> >> $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
> >> "BUILD","$*")
> >>
> >> @@ -99,6 +100,7 @@ docker:
> >> @echo ' (default is 1)'
> >> @echo ' DEBUG=1 Stop and drop to shell in the created
> >> container'
> >> @echo ' before running the command.'
> >> + @echo ' USER=1 Add current user to docker image.'
> >
> > This is a bad choice of name, $USER is "$(id -un)", maybe
> > ADD_CUR_USER?
>
> Or we could just enable it by default? Is there a reason not to enable
> the current user for these images?
I think that's fine, but then docker.py needs to tolerate user already existing
in the image, such as when you build qemu:debian-cross-$foo on top of
qemu:debian.
Fam
- [Qemu-devel] [PATCH v3 2/3] new: debian docker targets for cross-compiling, (continued)
[Qemu-devel] [PATCH v3 1/3] tests/docker: add basic user mapping support, Alex Bennée, 2017/02/14