Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created November 13, 2023 15:49
Show Gist options
  • Save xtetsuji/581bfecc28d7d56464bfd712761cdb12 to your computer and use it in GitHub Desktop.
Save xtetsuji/581bfecc28d7d56464bfd712761cdb12 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://docs.docker.com/engine/install/ubuntu/
set -eu
# root でなかったら終了
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." 1>&2
exit 1
fi
# Ubuntu でなかったら終了
# Debian であっても終了
if ! grep -q Ubuntu /etc/os-release; then
echo "This script must be run on Ubuntu." 1>&2
exit 1
fi
apt purge docker
apt install -y ca-certificates curl gnupg lsb-release
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io
@xtetsuji
Copy link
Author

xtetsuji commented May 28, 2024

Ubuntu moby-cli package brings /usr/bin/docker too, but this script purge docker package only. Is it safe?

(ja: Ubuntu の moby-cli パッケージも /usr/bin/docker を配置するんだけど、このスクリプトではサポートしていないの、大丈夫だろうか)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment