install-docker-debian.sh 946 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # NEW WAY
  4. sudo apt-get remove docker docker-engine docker.io containerd runc
  5. sudo apt-get update -y
  6. sudo apt-get install -y \
  7. ca-certificates \
  8. curl \
  9. gnupg \
  10. lsb-release
  11. sudo mkdir -p /etc/apt/keyrings
  12. curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  13. echo \
  14. "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  15. $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  16. sudo apt-get update -y
  17. sudo chmod a+r /etc/apt/keyrings/docker.gpg
  18. sudo apt-get update -y
  19. sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  20. # sudo docker run hello-world
  21. sudo groupadd docker
  22. sudo usermod -aG docker "$USER"
  23. sudo gpasswd -a "$USER" docker
  24. newgrp docker
  25. sudo systemctl enable --now docker