Handle DOCKER_HOST environment for podman-docker package

Rootless users should be defaulted to point DOCKER_HOST at
$XDG_RUNTIME_DIR/podman/podman.sock

When podman-docker package is installed.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2024-02-12 16:05:38 -05:00
parent 36853c0d06
commit ad55ba6eb2
5 changed files with 27 additions and 2 deletions

4
docker/docker.in Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
[ -e ${ETCDIR}/containers/nodocker ] || \
echo "Emulate Docker CLI using podman. Create ${ETCDIR}/containers/nodocker to quiet msg." >&2
exec ${BINDIR}/podman "$@"

10
docker/podman-docker.csh Normal file
View File

@ -0,0 +1,10 @@
# DOCKER_HOST initialization
if ($?DOCKER_HOST) exit
if ( "$euid" == 0 ) then
setenv DOCKER_HOST unix:///run/podman/podman.sock
else
if ($?XDG_RUNTIME_DIR) then
setenv DOCKER_HOST unix://$XDG_RUNTIME_DIR/podman/podman.sock
endif
endif

11
docker/podman-docker.sh Normal file
View File

@ -0,0 +1,11 @@
# DOCKER_HOST initialization
if [ -z "$DOCKER_HOST" ]; then
if [ $(id -u) -eq 0 ]; then
export DOCKER_HOST=unix:///run/podman/podman.sock
else
if [ -n "$XDG_RUNTIME_DIR" ]; then
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
fi
fi
fi