Install and configure docker and docker-compose based on CentOS7

Docker is a cloud open source project based on the Go language.
The main goal of Docker is " Build, Ship and Run Any App, Anywhere" , that is, through the management of the life cycle of application components such as packaging, distribution, deployment, and operation, the user's APP (which can be a WEB application or database application etc.) and its operating environment can achieve "mirror once, run everywhere".
The emergence of Linux container technology solves such a problem, and Docker is developed on the basis of it. The application is mirrored, and the mirror becomes an instance running on the Docker container, and the Docker container is consistent on any operating system, which realizes cross-platform and cross-server. You only need to configure the environment once, and you can deploy it on another machine with one click, which greatly simplifies the operation.

To put it simply, docker is a software container that solves the problem of operating environment and configuration, and is a container virtualization technology that facilitates continuous integration and contributes to the overall release.
docker
insert image description here

1. Install and configure docker

1.1 Install and configure docker detailed commands

#一、安装docker
#1-安装yum工具  -y表示安装过程中,默认所有选项都为y,这样设置就不需要暂停了。
yum install -y yum-utils device-mapper-persistent-data lvm2


#2-设置docker镜像源  【##推荐##】
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#更新yum软件包    执行成功会显示“元数据缓存已建立”
 yum makecache fast


#3-安装docker,默认安装最新版本 【##推荐##】
yum -y install docker-ce


#4-启动docker前关闭防火墙
#关闭 防火墙
systemctl stop firewalld
#禁止开机启动防火墙
systemctl disable firewalld
#查看防火墙状态
systemctl status firwwalld

#5-启动docker
systemctl start docker
#设置  开机启动docker
systemctl enable docker.service 或systemctl enable docker
#查看是否启动成功:
(1)查看状态:
systemctl status docker2)查看版本
docker -v

#6-设置国内镜像   配置镜像加速,docker官方镜像仓库网速较差,我们需要设置国内镜像服务
sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
    
    
  "registry-mirrors": ["https://ds56c2e4.mirror.aliyuncs.com"]
}
EOF



#重新加载
sudo systemctl daemon-reload
#重启docker
sudo systemctl restart docker

1.2 Installation configuration docker screenshot

insert image description here
insert image description here
insert image description here
insert image description here

insert image description here

insert image description here
insert image description here
insert image description here
insert image description here

2. Install and configure docker-compose

2.1 Obtain from GitHub

Get it directly through GitHub and the curl command:

#Choose the version you want to install Modify the following statement version number
curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose- ( uname − s ) − (uname -s )-( u name es)(uname -m) -o /usr/local/bin/docker-compose

Because domestic access to GitHub, the access situation is good and bad, sometimes it will convulse and cannot be opened directly. If you want to speed up domestic GitHub access, you can refer to my article: Speed ​​up domestic GitHub access through FastGithub under Windows .

2.2 Manual download [recommended]

Click on the network disk to download

#手动安装
下载好之后 上传到系统 /usr/local/bin 目录 并改名为 docker-compose
这里使用的是docker-compose-linux-x86_64_2.2.2,下载好之后,保存到本地硬盘,通过软件上传到centos系统 /usr/local/bin 目录 并改名为 docker-compose。


#授权让当前文件是可以执行的,允许执行,有执行的权限。
chmod +x /usr/local/bin/docker-compose

#检查版本,正常情况下会显示:Docker Compose version v2.2.2
#2.2.2
docker-compose -version

#1.27.4
docker-compose -version

2.3 Install and configure docker-compose

Download docker-compose-linux-x86_64_2.2.2 :
insert image description here
insert image description here

insert image description here

insert image description here
insert image description here
insert image description here
docker-compose启动redis:Can‘t open the append-only file: permission deined

3. References

Install Docker Engine on CentOS
Use the Docker command line
Dockerfile referenceAlibaba
Cloud's Image Acceleration
DocumentAlibaba Cloud Image AcceleratorDocker
CE Image Source Station

Guess you like

Origin blog.csdn.net/qyfx123456/article/details/131525672