Message ID | 1476850246-12883-1-git-send-email-christian@paral.in |
---|---|
State | Changes Requested, archived |
Headers | show |
Hello, On Wed, 19 Oct 2016 00:10:46 -0400, Christian Stewart wrote: > Adds an option to selectively enable a static client. > > This is useful when bind-mounting the docker client binary into > containers for a docker-in-docker setup. > > Signed-off-by: Christian Stewart <christian@paral.in> We normally don't provide per-package options to build statically. Indeed, if we were to start doing this, we would have to create one additional option for every package in Buildroot. Though, if there's a really serious use-case for having just the docker client built statically, maybe we can make an exception. Thanks, Thomas
>>>>> "Christian" == Christian Stewart <christian@paral.in> writes: > Adds an option to selectively enable a static client. > This is useful when bind-mounting the docker client binary into > containers for a docker-in-docker setup. > Signed-off-by: Christian Stewart <christian@paral.in> What is the use case for docker-in-docker? Why not bind mount /var/run/docker.sock instead?
Hi Peter, On Wed, Oct 19, 2016 at 3:53 AM, Peter Korsgaard <peter@korsgaard.com> wrote: > What is the use case for docker-in-docker? Why not bind mount > /var/run/docker.sock instead? You need the Docker client if you want to call Docker from bash inside a container. This is intended for use along with bind mounting the docker.sock in the container. To guarantee you have the same client version in the host and the docker container, it's then easier to just bind mount both docker.sock and the docker client into the container. You need a static client to make sure this always works. This is why I added this option and have been using it myself for a long time. Running Docker inside Docker is actually another thing altogether and completely possible, and I do this to run an entire Buildroot / SystemD based system inside Docker: https://github.com/paralin/SkiffOS/blob/master/docker/Dockerfile In this way I can compile an entire Skiff (buildroot) system on Jenkins and run end-to-end tests against a Kubernetes cluster, orchestrating the Systemd-And-Docker-In-Docker containers over a cluster of servers. Best, Christian Stewart
Peter, Thomas, On Wed, Oct 19, 2016 at 1:28 PM, Christian Stewart <christian@paral.in> wrote: > On Wed, Oct 19, 2016 at 3:53 AM, Peter Korsgaard <peter@korsgaard.com> wrote: >> What is the use case for docker-in-docker? Why not bind mount >> /var/run/docker.sock instead? > > You need the Docker client if you want to call Docker from bash inside > a container. This is intended for use along with bind mounting the > docker.sock in the container. To guarantee you have the same client > version in the host and the docker container, it's then easier to just > bind mount both docker.sock and the docker client into the container. > You need a static client to make sure this always works. This is why I > added this option and have been using it myself for a long time. I'm revisiting this pending patch as I don't think we came to a conclusion on if it would be merged or not. I'm using the option extensively in my projects, so I still believe it's worth merging. Thoughts on this? Thanks, Christian Stewart
Hello, On Wed, 19 Oct 2016 00:10:46 -0400, Christian Stewart wrote: > Adds an option to selectively enable a static client. > > This is useful when bind-mounting the docker client binary into > containers for a docker-in-docker setup. > > Signed-off-by: Christian Stewart <christian@paral.in> Since there hasn't been much opposition to your patch, I want to merge it. Could you however send an updated version that applies to the latest master, and with an improved commit log and Config.in help text, based on the justification you gave to Peter? Thanks! Thomas
Hi Thomas, On Tue, Mar 7, 2017 at 3:23 PM, Thomas Petazzoni < thomas.petazzoni@free-electrons.com> wrote: > > Since there hasn't been much opposition to your patch, I want to merge > it. Could you however send an updated version that applies to the > latest master, and with an improved commit log and Config.in help text, > based on the justification you gave to Peter? > I had intended to just reply with the patch, but I've been pretty tied up for the past few days. I plan to finish this later this week. Best, Christian
diff --git a/package/docker-engine/Config.in b/package/docker-engine/Config.in index b9b9aac..1756977 100644 --- a/package/docker-engine/Config.in +++ b/package/docker-engine/Config.in @@ -25,6 +25,12 @@ config BR2_PACKAGE_DOCKER_ENGINE_DAEMON config BR2_PACKAGE_DOCKER_ENGINE_EXPERIMENTAL bool "build experimental features" +config BR2_PACKAGE_DOCKER_ENGINE_STATIC_CLIENT + bool "build static client" + depends on !BR2_STATIC_LIBS + help + Build a static docker client. + if BR2_PACKAGE_DOCKER_ENGINE_DAEMON config BR2_PACKAGE_DOCKER_ENGINE_DRIVER_BTRFS diff --git a/package/docker-engine/docker-engine.mk b/package/docker-engine/docker-engine.mk index 3d39aac..b95b9a2 100644 --- a/package/docker-engine/docker-engine.mk +++ b/package/docker-engine/docker-engine.mk @@ -25,8 +25,13 @@ DOCKER_ENGINE_GLDFLAGS = \ ifeq ($(BR2_STATIC_LIBS),y) DOCKER_ENGINE_GLDFLAGS += -extldflags '-static' +else +ifeq ($(BR2_PACKAGE_DOCKER_ENGINE_STATIC_CLIENT),y) +DOCKER_ENGINE_GLDFLAGS_DOCKER += -extldflags '-static' +endif endif + DOCKER_ENGINE_BUILD_TAGS = cgo exclude_graphdriver_zfs autogen DOCKER_ENGINE_BUILD_TARGETS = docker @@ -93,7 +98,7 @@ define DOCKER_ENGINE_BUILD_CMDS $(HOST_DIR)/usr/bin/go build -v \ -o $(@D)/bin/$(target) \ -tags "$(DOCKER_ENGINE_BUILD_TAGS)" \ - -ldflags "$(DOCKER_ENGINE_GLDFLAGS)" \ + -ldflags "$(DOCKER_ENGINE_GLDFLAGS) $(DOCKER_ENGINE_GLDFLAGS_$(call UPPERCASE,$(target)))" \ ./cmd/$(target) ) endef
Adds an option to selectively enable a static client. This is useful when bind-mounting the docker client binary into containers for a docker-in-docker setup. Signed-off-by: Christian Stewart <christian@paral.in> --- package/docker-engine/Config.in | 6 ++++++ package/docker-engine/docker-engine.mk | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)