Skip to content

Docker rootless support #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,15 @@ [email protected]
# https://github.com/nginx-proxy/nginx-proxy#default-host
#
DEFAULT_HOST=

#-----------------------------------------------------------------------
#
# Docker Rootless
#
# In case you want to use this proxy on Docker Rootless (DR) and you also have followed
# the DR installation from the official documentation (https://docs.docker.com/engine/security/rootless/)
# Set the following value of the DOCKER_HOST variable that you got in the final info messages after executing
# the "$ dockerd-rootless-setuptool.sh install" command.
# For example DOCKER_HOST_PATH=$XDG_RUNTIME_DIR/docker.sock
# If you are not using Docker Rootless, leave this variable blank
DOCKER_HOST_ROOTLESS_PATH=
20 changes: 20 additions & 0 deletions bin/fresh-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ while [[ $# -gt 0 ]]; do
shift 1
;;

# Docker rootless support
-dr)
USE_DOCKER_ROOTLESS=true
shift 1
;;
--docker-rootless)
USE_DOCKER_ROOTLESS=true
shift 1
;;

# IPv4 options
--ipv4-subnet=*)
ARG_IPv4_SUBNET="${1#*=}"
Expand Down Expand Up @@ -1121,6 +1131,16 @@ DOCKER_HTTPS=${ARG_DOCKER_HTTPS:-"443"}
#-----------------------------------------------------------------------
SSL_POLICY=${ARG_SSL_POLICY:-"Mozilla-Intermediate"}

#-----------------------------------------------------------------------
# Docker rootless support. Add the current user's docker.sock path (default: blank)
# Please read the official documentation of installing Docker Rootless:
# https://docs.docker.com/engine/security/rootless/
#-----------------------------------------------------------------------
if [[ "$USE_DOCKER_ROOTLESS" == true ]]; then
# Get the current user's $XDG_RUNTIME_DIR and concat with the '/docker.sock'
DOCKER_HOST_ROOTLESS_PATH=`echo ${XDG_RUNTIME_DIR}/docker.sock`
fi

#-----------------------------------------------------------------------
# Start actions!
#-----------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions bin/localscript/update-env-new-site-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@ local_update_env_new_site_variables()
# Default host
[[ ! $ARG_DEFAULT_HOST == "" ]] && run_function env_update_variable $LOCAL_FILE_PATH "DEFAULT_HOST" "${ARG_DEFAULT_HOST}"

# Docker rootless support
run_function env_update_variable $LOCAL_FILE_PATH "DOCKER_HOST_ROOTLESS_PATH" "$DOCKER_HOST_ROOTLESS_PATH"

return 0
}
5 changes: 5 additions & 0 deletions bin/localscript/usage-fresh-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Usage:
[--use-nginx-conf-files] [--update-nginx-template]
[--yes]
[--debug]
[--docker-rootless]

Required
-e | --default-email Default email address require to issue ssl
Expand Down Expand Up @@ -131,6 +132,10 @@ Usage:
--yes Set "yes" to all, use it with caution
--debug Show script debug options
--silent Hide all script message
-dr | --docker-rootless Add Docker rootless support by adding the
the current user's $XDG_RUNTIME_DIR and
concat with the '/docker.sock' in the
DOCKER_HOST_ROOTLESS_PATH .env file.
-h | --help Display this help

${reset}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
- ${NGINX_FILES_PATH:-./data}/html:/usr/share/nginx/html
- ${NGINX_FILES_PATH:-./data}/certs:/etc/nginx/certs:ro
- ${NGINX_FILES_PATH:-./data}/htpasswd:/etc/nginx/htpasswd:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
- ${DOCKER_HOST_ROOTLESS_PATH:-/var/run/docker.sock}:/tmp/docker.sock:ro
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
logging:
driver: ${NGINX_GEN_LOG_DRIVER:-json-file}
Expand All @@ -57,7 +57,7 @@ services:
- ${NGINX_FILES_PATH:-./data}/html:/usr/share/nginx/html
- ${NGINX_FILES_PATH:-./data}/certs:/etc/nginx/certs:rw
- ${NGINX_FILES_PATH:-./data}/acme.sh:/etc/acme.sh
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${DOCKER_HOST_ROOTLESS_PATH:-/var/run/docker.sock}:/var/run/docker.sock:ro
environment:
NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN_SEVICE_NAME:-nginx-proxy-automation-gen}
NGINX_PROXY_CONTAINER: ${NGINX_WEB_SEVICE_NAME:-nginx-proxy-automation-web}
Expand Down