mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #19886 from AndrewGuenther/185160-init-socket-fix
Wait to fire start event until socket is created
This commit is contained in:
commit
d47812dd1d
1 changed files with 11 additions and 3 deletions
|
@ -46,15 +46,23 @@ end script
|
|||
# See https://github.com/docker/docker/issues/6647
|
||||
post-start script
|
||||
DOCKER_OPTS=
|
||||
DOCKER_SOCKET=
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
|
||||
if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
|
||||
while ! [ -e /var/run/docker.sock ]; do
|
||||
DOCKER_SOCKET=/var/run/docker.sock
|
||||
else
|
||||
DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)\W*unix://\K(\S+)')
|
||||
fi
|
||||
|
||||
if [ -n "$DOCKER_SOCKET" ]; then
|
||||
while ! [ -e "$DOCKER_SOCKET" ]; do
|
||||
initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
|
||||
echo "Waiting for /var/run/docker.sock"
|
||||
echo "Waiting for $DOCKER_SOCKET"
|
||||
sleep 0.1
|
||||
done
|
||||
echo "/var/run/docker.sock is up"
|
||||
echo "$DOCKER_SOCKET is up"
|
||||
fi
|
||||
end script
|
||||
|
|
Loading…
Add table
Reference in a new issue