11.install_docker.sh 936 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. # Set superuser privileges command if not set
  7. if [[ -z $su ]]; then
  8. export su="sudo"
  9. fi
  10. # Installation https://docs.docker.com/engine/install/ubuntu/
  11. $su apt-get -y update
  12. $su apt-get install ca-certificates curl gnupg lsb-release
  13. $su mkdir -p /etc/apt/keyrings
  14. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | $su gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  15. echo \
  16. "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  17. $(lsb_release -cs) stable" | $su tee /etc/apt/sources.list.d/docker.list > /dev/null
  18. $su apt-get -y update
  19. $su apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  20. # Add user to docker group
  21. $su groupadd docker || true
  22. $su gpasswd -a $USER docker || true
  23. echo "NOTE: You need to restart user session to use docker without sudo"