Browse Source

fix: [docker-host] restart docker only if necessary

postgres
Valentin Lab 6 years ago
parent
commit
fff43fa397
  1. 13
      precise/host/hooks/install.d/60-docker.sh

13
precise/host/hooks/install.d/60-docker.sh

@ -1,17 +1,26 @@
#!/bin/bash #!/bin/bash
need_restart=
if ! type -p docker; then if ! type -p docker; then
echo "Installing docker..." echo "Installing docker..."
curl -sSL https://get.docker.io | sh curl -sSL https://get.docker.io | sh
fi fi
version="$(apt-cache madison docker-ce | cut -f 2 -d \| | grep 17.06 | head -n 1 | xargs echo)"
docker_version=17.06
if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then
version="$(apt-cache madison docker-ce | cut -f 2 -d \| | grep "$docker_version" | head -n 1 | xargs echo)"
## DOWNGRADE to 17.xx because 18.xx do not support registry v1 ## DOWNGRADE to 17.xx because 18.xx do not support registry v1
apt-get install -y --force-yes docker-ce="$version" apt-get install -y --force-yes docker-ce="$version"
need_restart=true
fi
if ! egrep 'disable-legacy-registry' /lib/systemd/system/docker.service 2>/dev/null; then if ! egrep 'disable-legacy-registry' /lib/systemd/system/docker.service 2>/dev/null; then
sed -ri 's/^(ExecStart=.*)$/\1 --disable-legacy-registry=false/g' /lib/systemd/system/docker.service sed -ri 's/^(ExecStart=.*)$/\1 --disable-legacy-registry=false/g' /lib/systemd/system/docker.service
need_restart=true
fi fi
if [ "$need_restart" ]; then
systemctl daemon-reload && systemctl daemon-reload &&
service docker restart service docker restart
fi
Loading…
Cancel
Save