一、查看操作系统版本
1、在Linux操作系统中,可以使用以下命令来查看操作系统版本:
$ cat /etc/os-release
查询结果:系统版本为 Centos 8
[root@06 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
[root@06 ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
2、用hostnamectl查询相关信息
$ hostnamectl
查询结果如下:操作系统为centos 8
[root@06 ~]# hostnamectl
Static hostname: 06.novalocal
Icon name: computer-vm
Chassis: vm
Machine ID: 88108a625cf94232b28252b637882a24
Boot ID: 9d2f87d14be5492e9407c1438d0489d9
Virtualization: kvm
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-80.el8.x86_64
Architecture: x86-64
二、查询系统的配置
1、所有信息 lscpu
$ lscpu
查询结果如下:CPU为16核
[root@06 ~]# lscpu
Architecture: x86_64 ##cpu架构
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16 ##总共有16核
On-line CPU(s) list: 0-15
Thread(s) per core: 2 ##每个cpu核,只能支持2个线程.
Core(s) per socket: 8 ##每个cpu,有8个核
Socket(s): 1 ##总共有1个cpu
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel Xeon Processor (Cascadelake)
Stepping: 6
CPU MHz: 2095.078
BogoMIPS: 4190.15
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0-15
2、查看内存信息
$ free -h
查询结果如下:内存为64G
[root@06 ~]# free -h
total used free shared buff/cache available
Mem: 62Gi 456Mi 61Gi 40Mi 413Mi 61Gi
Swap: 0B 0B 0B
3、查看磁盘信息
$ fdisk -l
查询结果如下:磁盘存储500G
[root@06 ~]# fdisk -l
Disk /dev/vda: 500 GiB, 536870912000 bytes, 1048576000 sectors #表示这是一个名为/dev/vda的硬盘,总容量为500 GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xeb6c4423
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 1026047 1024000 500M 83 Linux #占用500M
/dev/vda2 1026048 1048575966 1047549919 499.5G 83 Linux #占用499.5G
Disk /dev/vdb: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
三、查询是否安装过docker
1、操作命令如下,本机中没有安装docker
[root@06 ~]# docker -v
-bash: docker: command not found
[root@06 ~]# docker version
-bash: docker: command not found
[root@06 ~]# whereis docker
docker:
[root@06 ~]# which docker
/usr/bin/which: no docker in (/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin)
四、下载离线安装包
1、登录官网下载
从官网中选择相应的版本,我选择了最新的包,在联网的环境下载到本地备用
https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz
五、安装docker
1、在centos8中创建文件夹,执行以下命令
$ mkdir /data/iot #这里自己定义文件夹的名称
结果如下:
[root@06 iot]# pwd
/data/iot
2、把下载的 docker-24.0.6.tgz 上传到/data/iot
文件夹中,可以通过FinalShell工具
结果如下:
[root@06 iot]# pwd
/data/iot
[root@06 iot]# ll
total 68164
-rw-r--r-- 1 root root 69797795 Oct 8 16:42 docker-24.0.6.tgz
[root@06 iot]# ls
docker-24.0.6.tgz
3、解压软件包
使用以下命令
$ tar -zxvf docker-24.0.6.tgz
执行结果如下:
[root@06 iot]# tar -zxvf docker-24.0.6.tgz
docker/
docker/docker
docker/docker-init
docker/dockerd
docker/runc
docker/ctr
docker/containerd-shim-runc-v2
docker/containerd
docker/docker-proxy
4、复制docker目录下的文件到/usr/bin目录下
查看解压后的目录,我们可以发现都是一些可以执行文件,我们将这些文件全部复制到/usr/bin
目录下。
[root@06 docker]# ll
total 182244
-rwxr-xr-x 1 1000 1000 39129088 Sep 4 20:34 containerd
-rwxr-xr-x 1 1000 1000 12374016 Sep 4 20:34 containerd-shim-runc-v2
-rwxr-xr-x 1 1000 1000 19140608 Sep 4 20:34 ctr
-rwxr-xr-x 1 1000 1000 34752096 Sep 4 20:34 docker
-rwxr-xr-x 1 1000 1000 63346888 Sep 4 20:34 dockerd
-rwxr-xr-x 1 1000 1000 761712 Sep 4 20:34 docker-init
-rwxr-xr-x 1 1000 1000 1965694 Sep 4 20:34 docker-proxy
-rwxr-xr-x 1 1000 1000 15142440 Sep 4 20:34 runc
执行命令
[root@06 iot]# pwd
/data/iot
[root@06 iot]# cp docker/* /usr/bin/
5、创建docker.service文件
进入到/usr/lib/systemd/system/
目录下,我们编辑创建docker.service文件,用于管理docker服务,复制黏贴如下内容即可。
$ vim /usr/lib/systemd/system/docker.service
复制粘贴以下内容,进行保存wq!
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
-H tcp://0.0.0.0:4243 \
-H unix:///var/run/docker.sock \
--selinux-enabled=false \
--log-opt max-size=100m
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
执行操作如下
[root@06 iot]# cd /usr/lib/systemd/system/
[root@06 system]# pwd
/usr/lib/systemd/system
[root@06 system]# vim /usr/lib/systemd/system/docker.service
六、重新加载daemon-reload
[root@06 system]# systemctl daemon-reload
七、 启动docker
$ systemctl start docker
八、 查看docker版本
[root@06 system]# docker version
Client:
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:30:51 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:32:17 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.7.3
GitCommit: 7880925980b188f4c97b462f709d0db8e8962aff
runc:
Version: 1.1.9
GitCommit: v1.1.9-0-gccaecfc
docker-init:
Version: 0.19.0
GitCommit: de40ad0