Skip to content

Commit 556877a

Browse files
committed
Added a Shell script to Install the latest version of Docker and docker-compose
1 parent a44c83d commit 556877a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docker-ubuntu-install.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e
3+
#Uninstall old versions
4+
sudo apt-get remove docker docker-engine docker.io containerd runc
5+
#Update the apt package index:
6+
sudo apt-get update
7+
8+
#Install packages to allow apt to use a repository over HTTPS:
9+
10+
sudo apt-get install -y \
11+
apt-transport-https \
12+
ca-certificates \
13+
curl \
14+
gnupg-agent \
15+
software-properties-common
16+
17+
# Add docker's package signing key
18+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
19+
20+
# Add repository
21+
sudo add-apt-repository -y \
22+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
23+
$(lsb_release -cs) \
24+
stable"
25+
26+
# Install latest stable docker stable version
27+
sudo apt-get update
28+
sudo apt-get -y install docker-ce
29+
30+
# Enable & start docker
31+
sudo systemctl enable docker
32+
sudo systemctl start docker
33+
34+
# add current user to the docker group to avoid using sudo when running docker
35+
sudo usermod -a -G docker $USER
36+
37+
# Install docker-compose
38+
39+
# get latest docker compose released tag
40+
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
41+
42+
sudo curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
43+
44+
sudo chmod a+x /usr/local/bin/docker-compose
45+
46+
# Output compose version
47+
docker -v
48+
docker-compose -v
49+
50+
echo "Installation Completed!"

0 commit comments

Comments
 (0)