One command to install Docker and Docker compose on Ubuntu

Installation by one command

The Command

Copy & paste the following command then enjoy your teatime during the installation process:

/bin/bash -c "$(curl -fsSL https://git.io/JDGfm)"

Once the script runs successfully, you need to refresh the current user state by executing the command below:

sudo su -l $USER. Or see other workarounds here [3].

Now the docker environment has been set up completely.

Want to know more, see the content below.

OS requirements

  • Ubuntu Impish 21.10
  • Ubuntu Hirsute 21.04
  • Ubuntu Focal 20.04 (LTS) ( Tested on it)
  • Ubuntu Bionic 18.04 (LTS)

Description

After installing Docker on Ubuntu several times, a shell script was created to make this process easier.

As laziness is one of the three great virtues of a programmer[1], you may prefer to copy & paste the following command line to get Docker ready on your Ubuntu.

/bin/bash -c “$(curl -fsSL https://git.io/JDGfm)"

However, if you wanna dig into the script, you can have a look at the following code (it is basically from Docker official guide [2]), and I just make it simpler to use.

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
sudo rm -rf /usr/share/keyrings/docker-archive-keyring.gpgcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get updatesudo apt-get install -y docker-ce docker-ce-cli containerd.iosudo usermod -a -G docker $USERsudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

References:

[1] https://avdi.codes/the-three-virtues/

[2] https://docs.docker.com/engine/install/ubuntu/

[3] https://askubuntu.com/questions/250720/is-it-necessary-to-reboot-after-changing-group-membership

--

--

--

Experienced Ruby on Rails enthusiast. Rich experience in software development. Proficient in Ruby/Python, Go/C/C++ and Javascript. Interested in DevOps.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Phase 1: Exploring Openvidu and RTSP

LikeCoin Weekly Progress Update 2020.07.20

My first Python Project

Why (I think) white board interviews matter

A Complete Guide to Laravel 5.8 Installation

Flask test CICD pipeline

Devops Week News — Issue #70

How to patch meltdown cpu vulnerability cve 2017 5754 on linux

Metaprogramming in Ruby

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matt Wang

Matt Wang

Experienced Ruby on Rails enthusiast. Rich experience in software development. Proficient in Ruby/Python, Go/C/C++ and Javascript. Interested in DevOps.

More from Medium

Docker Networking

K8’s on Laptop : First Proxy

Demystifying Docker

Getting Started with Kubernetes as a Developer