CentOS installs docker and docker-compose

Install the docker engine on the CentOS system:

System: CentOS 

docker官网:Install Docker Engine on CentOS | Docker Documentation

## Uninstall the previous docker (uninstall if there is one)

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

##Install yum dependencies

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

##Alibaba cloud image source:

#sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

## Tsinghua University mirror source:

#sudo yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

## List the versions available in the docker repository

yum list docker-ce --showduplicates | sort -r

##Install the specified version

## Install a specific version by its full package name, which is the package name (docker-ce) plus the version string (second column), from the first colon (:) all the way to the first hyphens and separate them with a hyphen (-). For example: docker-ce-18.09.1.

#sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

##Default installation docker default latest version

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

## If there is an error in centos8 :  Question 1: The problem with the installed package podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64   - package podman-1.4.2-5.module_el8.1.0+237 +63e26edc.x86_64 requires runc, but no provider can be installed   - package podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 requires runc >= 1.0.0-57, but no provider can be installed INSTALL   - Package containerd.io-1.6.21-3.1.el8.x86_64 conflicts with runc (provided by runc-1.0.0-60.rc8.module_el8.1.0+237+63e26edc.x86_64)



The description conflicts with the podman package 

Excuting an order:

yum erase podman buildah

# can be solved

## start docker

sudo systemctl start docker

##View docker running status

systemctl status docker

## stop docker

systemctl stop docker

##Configure docker to start automatically

systemctl enable docker

##View docker version number

docker --version


Install docker-compose

docker official website: docker official website installation

##Official installation image

curl -SL https://github.com/docker/compose/releases/download/v2.19.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

## To install other versions of Compose, please replace v2.19.0 Current latest version: v2.19.0

##You can view the version list through GitHub: https://github.com/docker/compose/releases

##The official image may not be downloaded, use the following high-speed installation of Docker Compose v2.4.1

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.19.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

## Apply executable permissions to the binary
sudo chmod +x /usr/local/bin/docker-compose

##Create a soft link

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

##View the version number

docker-compose version

##docker-compose file content configuration can refer to: Docker Compose | rookie tutorial

If an error is reported:

/usr/local/bin/docker-compose: line 1: html: No such file or directory
/usr/local/bin/docker-compose: line 2: unexpected symbol `<' Syntax error near
'usr/local /bin/docker-compose: line 2: `<head><title>502 Bad Gateway</title></head>
indicating that the docker-compose file is incorrect

Open the official website: docker-compose version list

Or open it directly: Download
If you can’t download it, you can use the link shared by the author: Baidu cloud disk extraction code: nc6k

Find the corresponding version and click to download

Then upload to the server: /usr/local/bin/ directory

Rename the file:

mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

Granted permission:

chmod +x /usr/local/bin/docker-compose

Execute again:

docker-compose version

Guess you like

Origin blog.csdn.net/weixin_42599091/article/details/131401092