docker_jessie_deploy.sh
· 975 B · Bash
原始文件
#!/bin/bash
[ "$(cat /etc/debian_version | awk -F. {'print $1'})" -ne "8" ] && echo exit 1
echo "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" > \
/etc/apt/sources.list.d/docker.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0EBFCD88; \
aptitude install -y apt-transport-https ca-certificates bridge-utils; \
aptitude update; \
aptitude install -y docker-ce && \
update-rc.d docker enable && \
# https://gist.github.com/steakknife/9094991#file-run_me_001__install_docker_and_fixes-sh-L20-L22 (enable swap resource limiting)
sed -i 's/\(GRUB_CMDLINE_LINUX_DEFAULT="quiet\)"/\1 swapaccount=1"/' /etc/default/grub && \
update-grub && \
cat > /etc/cron.weekly/docker-cleanup <<EOF
#!/bin/bash
# See https://getintodevops.com/blog/keeping-the-whale-happy-how-to-clean-up-after-docker
#docker rmi $(docker images -q -f dangling=true)
docker volume rm $(docker volume ls -qf dangling=true)
EOF
chmod +x /etc/cron.weekly/docker-cleanup
| 1 | #!/bin/bash |
| 2 | [ "$(cat /etc/debian_version | awk -F. {'print $1'})" -ne "8" ] && echo exit 1 |
| 3 | echo "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" > \ |
| 4 | /etc/apt/sources.list.d/docker.list && \ |
| 5 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0EBFCD88; \ |
| 6 | aptitude install -y apt-transport-https ca-certificates bridge-utils; \ |
| 7 | aptitude update; \ |
| 8 | aptitude install -y docker-ce && \ |
| 9 | update-rc.d docker enable && \ |
| 10 | # https://gist.github.com/steakknife/9094991#file-run_me_001__install_docker_and_fixes-sh-L20-L22 (enable swap resource limiting) |
| 11 | sed -i 's/\(GRUB_CMDLINE_LINUX_DEFAULT="quiet\)"/\1 swapaccount=1"/' /etc/default/grub && \ |
| 12 | update-grub && \ |
| 13 | cat > /etc/cron.weekly/docker-cleanup <<EOF |
| 14 | #!/bin/bash |
| 15 | # See https://getintodevops.com/blog/keeping-the-whale-happy-how-to-clean-up-after-docker |
| 16 | #docker rmi $(docker images -q -f dangling=true) |
| 17 | docker volume rm $(docker volume ls -qf dangling=true) |
| 18 | EOF |
| 19 | chmod +x /etc/cron.weekly/docker-cleanup |