Skip to content

Commit

Permalink
feat: rootless docker
Browse files Browse the repository at this point in the history
made makefile resolve docker environment

Signed-off-by: jakeiotechsys <[email protected]>
  • Loading branch information
jakeiotechsys committed Aug 13, 2024
1 parent 5ed4bcd commit b96e896
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 5 additions & 4 deletions compose-builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compose-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Usage: make <target> 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
Expand Down
2 changes: 1 addition & 1 deletion compose-builder/add-delayed-start-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-portainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b96e896

Please sign in to comment.