diff --git a/Makefile b/Makefile index 51f8f80d..825b8015 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,9 @@ DOCKER_COMPOSE=docker compose # Resolve user ID for rootless docker port mapping export USERID:=$(shell id -u) +# Set default rootful docker socket path +export DOCKER_SOCKET_PATH=/var/run/docker.sock + ifeq (arm64, $(filter arm64,$(ARGS))) ARM64=-arm64 ARM64_OPTION=arm64 @@ -55,10 +58,8 @@ endef .PHONY: $(OPTIONS) portainer: - @if [ ! -e /run/user/${USERID}/docker.sock ]; then \ - echo "Error: Docker socket not found at /run/user/${USERID}/docker.sock"; \ - echo "Please ensure Docker is running rootless."; \ - exit 1; \ + @if [ -e /run/user/${USERID}/docker.sock ]; then \ + export DOCKER_SOCKET_PATH=/run/user/${USERID}/docker.sock; \ fi ${DOCKER_COMPOSE} -p portainer -f docker-compose-portainer.yml up -d diff --git a/README.md b/README.md index 1aed3f6a..489ea137 100644 --- a/README.md +++ b/README.md @@ -125,4 +125,4 @@ The compose files under the `taf` subfolder are used for the automated TAF tests - **docker-compose-portainer.yml** Stand-alone compose file for running Portainer which is a Docker container management tool. Visit here https://www.portainer.io/ for more details on Portianer. - Use `make portainer`and `make portainer-down` to start and stop Portainer. This feature has been configured to run only in a rootless docker environment. + Use `make portainer`and `make portainer-down` to start and stop Portainer. diff --git a/compose-builder/Makefile b/compose-builder/Makefile index e504133b..f29e8962 100644 --- a/compose-builder/Makefile +++ b/compose-builder/Makefile @@ -39,6 +39,9 @@ REGISTRY= # Resolve user ID for rootless docker port mapping export USERID:=$(shell id -u) +# Set default rootful docker socket path +export DOCKER_SOCKET_PATH=/var/run/docker.sock + BROKER_YAML=add-mqtt-broker-mosquitto.yml TAF_BROKER_YAML=add-taf-mqtt-broker-mosquitto.yml @@ -138,10 +141,8 @@ endif # When in delay-start mode, we have to make sure support serivces be delayed-start-compliant: i.e. the runtime-token configuration be added etc.. ifeq (delayed-start, $(filter delayed-start,$(ARGS))) # Make sure docker is running rootless as security-spire-agent runs only in docker rootless mode - @if [ ! -e /run/user/${USERID}/docker.sock ]; then \ - echo "Error: Docker socket not found at /run/user/${USERID}/docker.sock"; \ - echo "Please ensure Docker is running rootless."; \ - exit 1; \ + @if [ -e /run/user/${USERID}/docker.sock ]; then \ + export DOCKER_SOCKET_PATH=/run/user/${USERID}/docker.sock; \ fi ext_file_sup_notif:= $(shell ZERO_TRUST="$(MAKE_ZERO_TRUST)" GEN_EXT_DIR="$(GEN_EXT_DIR)" ./gen_runtime_token_config_compose_ext.sh support-notifications) ext_file_sup_sch:= $(shell ZERO_TRUST="$(MAKE_ZERO_TRUST)" GEN_EXT_DIR="$(GEN_EXT_DIR)" ./gen_runtime_token_config_compose_ext.sh support-scheduler) diff --git a/compose-builder/README.md b/compose-builder/README.md index dc46debf..c1946ada 100644 --- a/compose-builder/README.md +++ b/compose-builder/README.md @@ -163,7 +163,7 @@ Usage: make where target is: #### Portainer ``` -portainer Runs Portainer independent of the EdgeX services and requires a rootless docker environment. +portainer Runs Portainer independent of the EdgeX services. portainer-down Stops Portainer independent of the EdgeX services ``` #### Build diff --git a/compose-builder/add-delayed-start-services.yml b/compose-builder/add-delayed-start-services.yml index 09005fe7..67356786 100644 --- a/compose-builder/add-delayed-start-services.yml +++ b/compose-builder/add-delayed-start-services.yml @@ -77,7 +77,7 @@ services: - spire-ca:/srv/spiffe/ca - spire-agent:/srv/spiffe/agent - /tmp/edgex/secrets/spiffe:/tmp/edgex/secrets/spiffe:z - - /run/user/${USERID}/docker.sock:/var/run/docker.sock + - ${DOCKER_SOCKET_PATH}:/var/run/docker.sock depends_on: - security-spire-server pid: host diff --git a/docker-compose-portainer.yml b/docker-compose-portainer.yml index ee7d899f..58ceb6be 100644 --- a/docker-compose-portainer.yml +++ b/docker-compose-portainer.yml @@ -27,6 +27,6 @@ services: restart: always command: -H unix:///var/run/docker.sock volumes: - - /run/user/${USERID}/docker.sock:/var/run/docker.sock + - ${DOCKER_SOCKET_PATH}:/var/run/docker.sock - portainer_data:/data