package/docker-engine: add option for static client
PATCH 1/1 package/docker-engine: add option for static client
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.
--- package/docker-engine/Config.in | 6 ++++++ package/docker-engine/docker-engine.mk | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
package/docker-engine/Config.in +6 -0
@@ -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
package/docker-engine/docker-engine.mk +6 -1
@@ -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
Signature · 1 line
2.7.3
PATCH 1/1 package/docker-engine: add option for static client
Hello,
Quoted 6 lines · Christian Stewart
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 <[email protected]>
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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/1 package/docker-engine: add option for static client
In reply to Christian StewartQuoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christian" == Christian Stewart <[email protected]> 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 <[email protected]>
What is the use case for docker-in-docker? Why not bind mount /var/run/docker.sock instead?
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/docker-engine: add option for static client
Hi Peter,
Quoted 2 lines · Peter Korsgaard
What is the use case for docker-in-docker? Why not bind mount
/var/run/docker.sockinstead?
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
PATCH 1/1 package/docker-engine: add option for static client
Peter, Thomas,
Quoted 11 lines · Christian Stewart
Quoted 2 lines · Peter Korsgaard
What is the use case for docker-in-docker? Why not bind mount
/var/run/docker.sockinstead?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
PATCH 1/1 package/docker-engine: add option for static client
In reply to Christian StewartHello,
Quoted 6 lines · Christian Stewart
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 <[email protected]>
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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/1 package/docker-engine: add option for static client
Hi Thomas,
Quoted 6 lines · Thomas Petazzoni
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170313/9f8e30f3/attachment.html>