Install docker
View system release version
cat /proc/version
1. Update apt package
sudo apt-get update
2. Install the necessary packages to allow apt to use the repository over HTTPS:
sudo apt-get install ca-certificates curl gnupg lsb-release
3. Add the GPG key of the official Docker repository:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
4. Set up the repository using the following command:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Update the apt package index and install the latest versions of Docker Engine, containerd and Docker Compose:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
6. Verify docker
sudo docker version
7. After the installation is complete, run the following command to verify whether the Docker service is running
systemctl status docker
8. If it is not running, run the following command to start the Docker service
sudo systemctl start docker
9. Set the Docker service to start automatically every time you turn on the computer
sudo systemctl enable docker
10. Test installation of an image
sudo docker run hello-world
11. View all images
sudo docker images
Note: If the installation in step 5 is slow, you can switch to the Alibaba Cloud image source to install Docker
1. Uninstall the Docker version that may exist or is successfully installed.
sudo apt-get remove docker docker-engine docker-ce docker.io
2. Add Alibaba Cloud’s GPG key
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
3. Set up the repository using the following command
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
Then proceed to step 5 above
Install docker-compose
download
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
To install a different version of Compose, replace v2.2.2
Add executable permissions
sudo chmod +x /usr/local/bin/docker-compose
Create a soft link:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Test whether the installation is successful:
docker-compose version