The following BASH script/function tries to install the latest version of the Docker via the get.docker.com site, if you have already installed docker, it will try to update it – however you should re-login to docker and re-connect to SSH afterwards.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/bin/bash install_docker() { sudo apt update # curl/git used by docker sudo apt install -y curl git curl https://get.docker.com | sh if [ "$EUID" -ne 0 ]; then echo "You need 'docker login' and 'service ssh restart' again" echo "for docker to function correctly" echo "Adding user $(whoami) to docker group" sudo usermod -aG docker $(whoami) fi } install_docker |
#!/bin/bash install_docker() { sudo apt update # curl/git used by docker sudo apt install -y curl git curl https://get.docker.com | sh if [ "$EUID" -ne 0 ]; then echo "You need 'docker login' and 'service ssh restart' again" echo "for docker to function correctly" echo "Adding user $(whoami) to docker group" sudo usermod -aG docker $(whoami) fi } install_docker
To install docker, you would also need to install some dependencies such as: curl and git.
BASH Programming/Shell
- How to Get HTTP Response Code using cURL Command?
- Three Interesting/Fun BASH Commands
- One Interesting Linux Command (Steam Locomotive in BASH)
- Simple Bash Function to Repeat a Command N times with Retries
- How to Extract a Domain Name from a Full URL in BASH?
- BASH Function to Compute the Greatest Common Divisor and Least Common Multiples
- BASH Function to Get Memory Information via AWK
- BASH Function to Escape Parameters Argument
- BASH Function to Check if sudo Available
- Full Permutation Algorithm Implementation in BASH
- BASH Function to Install Docker
- A Simple BASH Function/Script to Run a Command in Background
- BASH Script to Compute the Average Ping to a Domain
- A Bash Process Controller to Start, Stop and Restart an Daemon Program
- Linux BASH shell - Echo This if you get angry
- Bash SHELL, Chess Board Printing
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Teaching Kids Programming - Back Tracking Algorithm to Generate Parentheses
Next Post: Teaching Kids Programming - Breadth First Search Algorithm to Compute the Max Width of a Binary Tree