Skip to content
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

After docker service restart, portainer cannot connect to the endpoint #15

Merged
merged 5 commits into from
Jun 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion createlinks
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ event_actions('nethserver-docker-update', qw(
nethserver-docker-create-logs 10
nethserver-docker-enable-repository 10
nethserver-docker-create-network 20
nethserver-docker-create-portainer 20
nethserver-docker-create-portainer 95
nethserver-docker-create-aeria 20
nethserver-docker-macvlan-creation 20
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ docker run --detach \
--hostname portainer \
--network aqua \
--ip ${IpAddress} \
portainer/portainer
portainer/portainer \
-H unix:///var/run/docker.sock
1 change: 1 addition & 0 deletions root/etc/systemd/system/docker.service.d/nethserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ PartOf=network.service
ExecStart=
ExecStart=/usr/bin/dockerd --config-file=/etc/docker/docker.conf
ExecStartPost=/usr/libexec/dockerCreateMacVlan0
ExecStartPost=/usr/libexec/dockerRestartPortainer
5 changes: 2 additions & 3 deletions root/usr/libexec/dockerCreateMacVlan0
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ fi
/usr/sbin/ip addr add $macVlanNetwork dev macvlan0
/usr/sbin/ip link set macvlan0 up

dockerUP=$(systemctl is-active docker)
if [[ $dockerUP != 'active' ]]; then
echo "[WARNING] docker is down, exit"
if ! /usr/bin/docker ps &>/dev/null; then
echo "[WARNING] docker is down, Exit"
exit 0
fi

Expand Down
22 changes: 22 additions & 0 deletions root/usr/libexec/dockerRestartPortainer
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

#
# When docker is restarted Portainer cannot use the local endpoint unix:///var/run/docker.sock
#

if ! /usr/bin/docker ps &>/dev/null; then
echo "[WARNING] docker is down, Exit"
exit 0
fi

HasPortainer=$(docker ps -f name=portainer -q -a)

if [[ $? != 0 ]]; then
exit 1
fi

if [[ -z ${HasPortainer} ]]; then
exit 0
fi

/usr/bin/docker restart portainer