Skip to content

Commit

Permalink
Handle DOCKER_HOST environment for podman-docker package
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rhatdan committed Feb 12, 2024
1 parent 36853c0 commit ad55ba6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -875,10 +875,13 @@ install.completions:
install.docker:
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
$(eval INTERPOLATED_DOCKER_SCRIPT := $(shell mktemp))
env BINDIR=${BINDIR} ETCDIR=${ETCDIR} envsubst < docker.in > ${INTERPOLATED_DOCKER_SCRIPT}
env BINDIR=${BINDIR} ETCDIR=${ETCDIR} envsubst < docker/docker.in > ${INTERPOLATED_DOCKER_SCRIPT}
install ${SELINUXOPT} -m 755 ${INTERPOLATED_DOCKER_SCRIPT} $(DESTDIR)$(BINDIR)/docker
rm ${INTERPOLATED_DOCKER_SCRIPT}
install ${SELINUXOPT} -m 755 -d $(DESTDIR)${SYSTEMDDIR} $(DESTDIR)${USERSYSTEMDDIR} $(DESTDIR)${TMPFILESDIR} $(DESTDIR)${USERTMPFILESDIR}
install ${SELINUXOPT} -d -m 755 $(DESTDIR)${ETCDIR}/profile.d
install ${SELINUXOPT} -m 644 docker/podman-docker.sh $(DESTDIR)${ETCDIR}/profile.d/podman-docker.sh
install ${SELINUXOPT} -m 644 docker/podman-docker.csh $(DESTDIR)${ETCDIR}/profile.d/podman-docker.csh
install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-docker.conf -t $(DESTDIR)${TMPFILESDIR}
install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-docker.conf -t $(DESTDIR)${USERTMPFILESDIR}

Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions docker/podman-docker.csh
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions docker/podman-docker.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion rpm/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ LDFLAGS=''

%install
install -dp %{buildroot}%{_unitdir}
PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{_sysconfdir} \
PODMAN_VERSION=%{version} %{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} ETCDIR=%{_sysconfdir} \
install.bin \
install.man \
install.systemd \
Expand Down Expand Up @@ -300,6 +300,7 @@ cp -pav test/system %{buildroot}/%{_datadir}/%{name}/test/
%files docker
%{_bindir}/docker
%{_mandir}/man1/docker*.1*
%{_sysconfdir}/profile.d/%{name}-docker.*
%{_tmpfilesdir}/%{name}-docker.conf
%{_user_tmpfilesdir}/%{name}-docker.conf

Expand Down

0 comments on commit ad55ba6

Please sign in to comment.