網(wǎng)站建設(shè)與開發(fā)論文谷歌seo是什么意思
Docker 筆記(一)–安裝
記錄Docker 安裝操作記錄,便于查詢。
參考
- 鏈接: Docker 入門到實戰(zhàn)教程(二)安裝Docker
- 鏈接: docker入門(利用docker部署web應(yīng)用)
- 鏈接: 阿里云容器鏡像服務(wù)/鏡像加速器/操作文檔
- 鏈接: 網(wǎng)易鏡像中心
- 鏈接: 阿里云鏡像站
環(huán)境
Centos 7.9
安裝
1.檢查操作系統(tǒng)環(huán)境和版本
Docker 要求 CentOS 系統(tǒng)的內(nèi)核版本高于 3.10,系統(tǒng)為64位
[root@centos7-18 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
Red Hat Enterprise Linux Server release 4.5 (Tikanga)
[root@centos7-18 ~]#
[root@centos7-18 ~]# uname -r
3.10.0-1160.6.1.el7.x86_64
[root@centos7-18 ~]#
2.如果安裝過,需要先卸載
yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
3.安裝Docker
3.1 安裝依賴
[root@centos7-18 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
3.2 添加Docker源
使用阿里云的Docker源
[root@centos7-18 yum.repos.d]#yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo已加載插件:fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@centos7-18 yum.repos.d]# ll /etc/yum.repos.d/
總用量 60
-rw-r--r--. 1 root root 2523 6月 16 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 11月 30 2016 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
// Docker源
-rw-r--r-- 1 root root 2081 11月 15 2023 docker-ce.repo
-rw-r--r--. 1 root root 1050 11月 1 2020 epel.repo
-rw-r--r--. 1 root root 1149 11月 1 2020 epel-testing.repo
3.3 安裝最新版
[root@centos7-18 yum.repos.d]# sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
安裝說明: 摘自《功能解釋:containerd.io、docker-ce、docker-ce-cli、docker-buildx-plugin、docker-compose-plugin、docker.io》
-
docker containerd.io
是Docker容器運行時的核心組件之一,它負責(zé)管理和運行容器。它提供了容器的生命周期管理、鏡像管理、網(wǎng)絡(luò)管理等功能。 -
docker-ce
是Docker Community Edition的縮寫,是Docker的社區(qū)版本。它是一個開源的容器化平臺,提供了構(gòu)建、發(fā)布和運行容器的工具和服務(wù)。廣義來說,docker-ce包含了dockerd(Docker守護進程)、docker命令行工具、docker-compose等組件;狹義上來講,docker-ce 是與 docker containerd.io、docker-ce-cli 并列的服務(wù)組件。 -
docker-ce-cli
是Docker Community Edition的命令行工具(command line)。它提供了與Docker守護進程進行交互的命令行接口,可以用于管理和操作Docker容器、鏡像、網(wǎng)絡(luò)等。 -
docker-buildx-plugin
是Docker的一個插件,用于構(gòu)建多平臺的容器鏡像。它可以在一個構(gòu)建過程中同時構(gòu)建多個不同平臺的鏡像,例如x86、ARM等。這樣可以方便地為不同平臺的設(shè)備提供適配的容器鏡像。 -
docker-compose-plugin
是Docker的一個插件,用于管理和編排多個容器的運行。它可以通過一個單獨的配置文件定義多個容器之間的關(guān)系和依賴,然后通過簡單的命令就可以啟動、停止、刪除這些容器。
3.4 查看版本
[root@centos7-18 yum.repos.d]# docker version
Client: Docker Engine - CommunityVersion: 24.0.7API version: 1.43Go version: go1.20.10Git commit: afdd53bBuilt: Thu Oct 26 09:11:35 2023OS/Arch: linux/amd64Context: default
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
3.5 啟動Docker
[root@centos7-18 yum.repos.d]# systemctl start docker
// 添加開機自啟動
//[root@centos7-18 yum.repos.d]# systemctl enable docker
[root@centos7-18 yum.repos.d]# ps -ef | grep docker
root 12338 1 0 13:43 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 12792 9696 0 13:49 pts/0 00:00:00 grep --color=auto docker
[root@centos7-18 yum.repos.d]#
3.6 配置國內(nèi)鏡像源
{"registry-mirrors": [// 阿里云的配置詳見“容器鏡像服務(wù)”-“鏡像加速器”-“對應(yīng)的操作系統(tǒng)”"https://xxxxxxx.mirror.aliyuncs.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn","https://registry.docker-cn.com"]
}
[root@centos7-18 docker]# systemctl daemon-reload
[root@centos7-18 docker]# systemctl restart docker
[root@centos7-18 docker]# docker info
Client: Docker Engine - CommunityVersion: 24.0.7Context: defaultDebug Mode: falsePlugins:buildx: Docker Buildx (Docker Inc.)Version: v0.11.2Path: /usr/libexec/docker/cli-plugins/docker-buildxcompose: Docker Compose (Docker Inc.)Version: v2.21.0Path: /usr/libexec/docker/cli-plugins/docker-composeServer:Containers: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 24.0.7Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueUsing metacopy: falseNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: cgroupfsCgroup Version: 1Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogSwarm: inactiveRuntimes: io.containerd.runc.v2 runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523runc version: v1.1.9-0-gccaecfcinit version: de40ad0Security Options:seccompProfile: builtinKernel Version: 3.10.0-1160.6.1.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 1.791GiBName: centos7-18.localdomainID: ff9448d2-60cd-4dfb-8d41-26afa972b45bDocker Root Dir: /var/lib/dockerDebug Mode: falseExperimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://xxxxxxxx.mirror.aliyuncs.com/http://hub-mirror.c.163.com/https://docker.mirrors.ustc.edu.cn/https://registry.docker-cn.com/Live Restore Enabled: false
鏡像源
網(wǎng)易:http://hub-mirror.c.163.com
中科大鏡像地址:http://mirrors.ustc.edu.cn/
中科大github地址:https://github.com/ustclug/mirrorrequest
Azure中國鏡像地址:http://mirror.azure.cn/
Azure中國github地址:https://github.com/Azure/container-service-for-azure-china
DockerHub鏡像倉庫: https://hub.docker.com/
阿里云鏡像倉庫: https://cr.console.aliyun.com
google鏡像倉庫: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墻的話是可以連上去的 )
coreos鏡像倉庫: https://quay.io/repository/
RedHat鏡像倉庫: https://access.redhat.com/containers