From 3aee35037a7773c66f0cdf75a6a276cfd53faa43 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 28 Aug 2020 13:34:20 +0200 Subject: [PATCH] Makefile: use --mount instead of -v for docker socket The shorthand `-v` will auto-create the host-path as a directory if the socket is not yet up, instead of failing the container. To prevent accidental creation of `/var/run/docker.sock` as a directory, use the `--mount` flag instead, which does not auto-create host-paths. Signed-off-by: Sebastiaan van Stijn --- docker.Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker.Makefile b/docker.Makefile index 69cb01215c..d30d56b4ce 100644 --- a/docker.Makefile +++ b/docker.Makefile @@ -100,7 +100,7 @@ plugins-osx: build_cross_image ## build the example CLI plugins for macOS .PHONY: dev dev: build_docker_image ## start a build container in interactive mode for in-container development $(DOCKER_RUN) -it \ - -v /var/run/docker.sock:/var/run/docker.sock \ + --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ $(DEV_DOCKER_IMAGE_NAME) shell: dev ## alias for dev @@ -145,15 +145,15 @@ test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ss .PHONY: test-e2e-experimental test-e2e-experimental: build_e2e_image # run experimental e2e tests - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 $(E2E_IMAGE_NAME) + docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 $(E2E_IMAGE_NAME) .PHONY: test-e2e-non-experimental test-e2e-non-experimental: build_e2e_image # run non-experimental e2e tests - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock $(ENVVARS) -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION) $(E2E_IMAGE_NAME) + docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION) $(E2E_IMAGE_NAME) .PHONY: test-e2e-connhelper-ssh test-e2e-connhelper-ssh: build_e2e_image # run experimental SSH-connection helper e2e tests - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 -e TEST_CONNHELPER=ssh $(E2E_IMAGE_NAME) + docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock $(ENVVARS) -e DOCKERD_EXPERIMENTAL=1 -e TEST_CONNHELPER=ssh $(E2E_IMAGE_NAME) .PHONY: help help: ## print this help