当前位置: 首页 > article >正文

第一节 docker基础之---安装

修改主机名:

[root@localhost ~]# hostnamectl set-hostname docker
[root@localhost ~]# bash
[root@docker ~]#

查看主机的内核版本(因为docker官方要求实在3.8以上)

[root@docker ~]# uname -a
Linux docker 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@docker ~]#
#3.10可以满足

关闭防火墙:

[root@docker ~]# systemctl stop firewalld

关闭Linux:

#原文件内容
[root@docker ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

#修改后文件内容:

[root@docker ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

通过安装wget命令后续来完成安装docker社区版:

[root@docker ~]# yum install wget -y

查看目前可安装docker版本:

[root@docker ~]# yum list | grep docker
cockpit-docker.x86_64                       195.12-1.el7.centos        extras
docker.x86_64                               2:1.13.1-209.git7d71120.el7.centos
docker-client.x86_64                        2:1.13.1-209.git7d71120.el7.centos
docker-client-latest.x86_64                 1.13.1-58.git87f2fab.el7.centos
docker-common.x86_64                        2:1.13.1-209.git7d71120.el7.centos
docker-distribution.x86_64                  2.6.2-2.git48294d9.el7     extras
docker-latest.x86_64                        1.13.1-58.git87f2fab.el7.centos
docker-latest-logrotate.x86_64              1.13.1-58.git87f2fab.el7.centos
docker-latest-v1.10-migrator.x86_64         1.13.1-58.git87f2fab.el7.centos
docker-logrotate.x86_64                     2:1.13.1-209.git7d71120.el7.centos
docker-lvm-plugin.x86_64                    2:1.13.1-209.git7d71120.el7.centos
docker-novolume-plugin.x86_64               2:1.13.1-209.git7d71120.el7.centos
docker-registry.x86_64                      0.9.1-7.el7                extras
docker-v1.10-migrator.x86_64                2:1.13.1-209.git7d71120.el7.centos
pcp-pmda-docker.x86_64                      4.3.2-13.el7_9             updates
podman-docker.noarch                        1.6.4-36.el7_9             extras
python-docker-py.noarch                     1:1.10.6-11.el7            extras
python-docker-pycreds.noarch                1:0.3.0-11.el7             extras
[root@docker ~]#
#上述安装包没有社区版咱们可以从阿里云的源中来下载获取当然也可以直接安装docker.x86_64

进入源目录配置阿里云

[root@docker ~]# cd /etc/yum.repos.d/
[root@docker yum.repos.d]# wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo                                     --2023-02-03 12:11:20--  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 140.249.32.238, 140.249.32.241, 140.249.32.242, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|140.249.32.238|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2081 (2.0K) [application/octet-stream]
正在保存至: “docker-ce.repo”

100%[==========================================================================================>] 2,081       --.-K/s 用时 0s

2023-02-03 12:11:20 (250 MB/s) - 已保存 “docker-ce.repo” [2081/2081])

[root@docker yum.repos.d]#

进行查看:

[root@docker yum.repos.d]# ls -lrt
总用量 44
-rw-r--r--. 1 root root  616 10月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root  630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root  314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 2081 2月   3 12:10 docker-ce.repo #可以看到这里有一个docker
[root@docker yum.repos.d]#

再次查看可安装的docker版本:

[root@docker yum.repos.d]# yum list | grep docker
cockpit-docker.x86_64                       195.12-1.el7.centos        extras
containerd.io.x86_64                        1.6.16-3.1.el7             docker-ce-stable
docker.x86_64                               2:1.13.1-209.git7d71120.el7.centos
docker-buildx-plugin.x86_64                 0.10.2-1.el7               docker-ce-stable
docker-ce.x86_64     #这里、、、                       3:23.0.0-1.el7             docker-ce-stable
docker-ce-cli.x86_64                        1:23.0.0-1.el7             docker-ce-stable
docker-ce-rootless-extras.x86_64            23.0.0-1.el7               docker-ce-stable
docker-ce-selinux.noarch                    17.03.3.ce-1.el7           docker-ce-stable
docker-client.x86_64                        2:1.13.1-209.git7d71120.el7.centos
docker-client-latest.x86_64                 1.13.1-58.git87f2fab.el7.centos
docker-common.x86_64                        2:1.13.1-209.git7d71120.el7.centos
docker-compose-plugin.x86_64                2.15.1-3.el7               docker-ce-stable
docker-distribution.x86_64                  2.6.2-2.git48294d9.el7     extras
docker-latest.x86_64                        1.13.1-58.git87f2fab.el7.centos
docker-latest-logrotate.x86_64              1.13.1-58.git87f2fab.el7.centos
docker-latest-v1.10-migrator.x86_64         1.13.1-58.git87f2fab.el7.centos
docker-logrotate.x86_64                     2:1.13.1-209.git7d71120.el7.centos
docker-lvm-plugin.x86_64                    2:1.13.1-209.git7d71120.el7.centos
docker-novolume-plugin.x86_64               2:1.13.1-209.git7d71120.el7.centos
docker-registry.x86_64                      0.9.1-7.el7                extras
docker-scan-plugin.x86_64                   0.23.0-3.el7               docker-ce-stable
docker-v1.10-migrator.x86_64                2:1.13.1-209.git7d71120.el7.centos
pcp-pmda-docker.x86_64                      4.3.2-13.el7_9             updates
podman-docker.noarch                        1.6.4-36.el7_9             extras
python-docker-py.noarch                     1:1.10.6-11.el7            extras
python-docker-pycreds.noarch                1:0.3.0-11.el7             extras
[root@docker yum.repos.d]#

进行安装docker社区版:

[root@docker yum.repos.d]# yum install docker-ce.x86_64 -y

设置开机自启:

[root@docker yum.repos.d]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@docker yum.repos.d]#

安装更新日志系统文件(否则可能会报错)

[root@docker ~]# yum install xfsprogs -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
软件包 xfsprogs-4.5.0-22.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@docker ~]#

启动docker:

[root@docker ~]# systemctl restart docker

查看docker服务启动情况:

[root@docker ~]# ps -ef | grep docker
root       2073      1  0 12:26 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root       2198   1752  0 12:28 pts/0    00:00:00 grep --color=auto docker
[root@docker ~]#正常启动
//
[root@docker ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2023-02-03 12:26:52 CST; 1min 46s ago
     Docs: https://docs.docker.com
 Main PID: 2073 (dockerd)
    Tasks: 7
   Memory: 100.7M
   CGroup: /system.slice/docker.service
           └─2073 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.584554775+08:00" level=info msg="[core] [Channel #4 SubCh...le=grpc
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.584592507+08:00" level=info msg="[core] [Channel #4] Chan...le=grpc
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.597022989+08:00" level=info msg="Loading containers: start."
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.725787229+08:00" level=info msg="Default bridge (docker0)...ddress"
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.777153908+08:00" level=info msg="Loading containers: done."
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.808877009+08:00" level=info msg="Docker daemon" commit=d7...=23.0.0
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.808971789+08:00" level=info msg="Daemon has completed ini...zation"
2月 03 12:26:52 docker systemd[1]: Started Docker Application Container Engine.
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.822648772+08:00" level=info msg="[core] [Server #7] Serve...le=grpc
2月 03 12:26:52 docker dockerd[2073]: time="2023-02-03T12:26:52.841132066+08:00" level=info msg="API listen on /run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@docker ~]#

查看docker的版本:

[root@docker ~]# docker version
Client: Docker Engine - Community
 Version:           23.0.0
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        e92dd87
 Built:             Wed Feb  1 17:49:02 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.0
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       d7573ab
  Built:            Wed Feb  1 17:46:49 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.16
  GitCommit:        31aa4358a36870b21a992d3ad2bef29e1d693bec
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@docker ~]#

查看docker的详细信息:

[root@docker ~]# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.15.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 23.0.0
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 31aa4358a36870b21a992d3ad2bef29e1d693bec
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-1160.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 972.3MiB
 Name: docker
 ID: ce24bf61-6e13-4004-988f-1777f98d9e74
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

[root@docker ~]#

http://www.kler.cn/a/538673.html

相关文章:

  • ChunkKV:优化 KV 缓存压缩,让 LLM 长文本推理更高效
  • UMLS初探
  • windows蓝牙驱动开发-蓝牙无线电重置和恢复
  • element-plus+vue3前端如何根据name进行搜索查到符合条件的数据
  • 【C语言标准库函数】指数与对数函数:exp(), log(), log10()
  • 【1】深入解析 SD-WAN:从思科 SD-WAN 视角看现代网络发展
  • torch_unbindtorch_chunk
  • 0207作业
  • DeepSeek 和 ChatGPT 的商业化发展前景对比
  • 深入浅出谈VR(虚拟现实、VR镜头)
  • 1、http介绍
  • 深入探究 C++17 std::is_invocable
  • LeetCode--300. 最长递增子序列【DP+二分】
  • 自动化测试工具selenium的安装踩坑
  • android隐藏虚拟按键recents button
  • Android的MQTT客户端实现
  • Qt实现简易视频播放器
  • Spring Boot 自动装配原理与优化实践
  • 算法与数据结构(合并K个升序链表)
  • C#面试常考随笔14: 方法如何传递不定数量的参数?params关键字怎么使用?
  • kafak最新安装教程【kafka_2.13-3.9.0】双语版
  • 电商行业的新篇章:3D和AR技术助力销售转化率提升!
  • 基于html和vue.js以及其他编程技术打造一个仿京东购物网站平台
  • c++学习笔记——c++基础
  • 【DeepSeek】DeepSeek概述 | 本地部署deepseek
  • Day81:数据的保存