Advertisement
Justman10000

Manage Docker

Sep 27th, 2024 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | None | 0 0
  1. // To install
  2. dockerVersion=$(curl -sL https://download.docker.com/linux/static/stable/x86_64 | grep -ioP '\d\d\.\d\.\d' | sort -rV | head -n 1)
  3. composeVersion=$(curl -sL https://api.github.com/repos/docker/compose/releases | grep -ioP 'v\d\.\d\d\.\d' | sort -rV | head -n 1)
  4. DOCKER_CONFIG=/root/.docker
  5.  
  6. wget https://download.docker.com/linux/static/stable/x86_64/docker-$dockerVersion.tgz
  7. gunzip docker-$dockerVersion.tgz
  8. tar xvf docker-$dockerVersion.tar
  9. mv docker/* /usr/bin
  10. rm -r docker*
  11.  
  12. mkdir -p $DOCKER_CONFIG/cli-plugins
  13. wget https://github.com/docker/compose/releases/download/$composeVersion/docker-compose-linux-x86_64 -O $DOCKER_CONFIG/cli-plugins/docker-compose
  14. chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
  15.  
  16. cat << EOF > /etc/systemd/system/docker.service
  17. [Unit]
  18. Description=Docker
  19. After=network.target
  20. Wants=network-online.target
  21.  
  22. [Service]
  23. Restart=always
  24. Type=simple
  25. ExecStart=/usr/bin/dockerd
  26. WorkingDirectory=
  27. Environment=
  28.  
  29. [Install]
  30. WantedBy=multi-user.target
  31. EOF
  32.  
  33. systemctl enable docker
  34. systemctl start docker
  35.  
  36. // To uninstall
  37. systemctl stop docker
  38. rm /etc/systemd/system/docker.service
  39. systemctl daemon reload
  40.  
  41. rm /usr/bin/containerd /usr/bin/containerd-shim-runc-v2 /usr/bin/ctr /usr/bin/docker /usr/bin/dockerd /usr/bin/docker-init /usr/bin/docker-proxy /usr/bin/log /usr/bin/runc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement