centos8離線安裝docker,實(shí)操案例

一、查看操作系統(tǒng)版本

1、在Linux操作系統(tǒng)中,可以使用以下命令來查看操作系統(tǒng)版本:

$ cat /etc/os-release

查詢結(jié)果:系統(tǒng)版本為 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查詢相關(guān)信息

$ hostnamectl

查詢結(jié)果如下:操作系統(tǒng)為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

二、查詢系統(tǒng)的配置

1、所有信息 lscpu

$ lscpu

查詢結(jié)果如下:CPU為16核

[root@06 ~]# lscpu
Architecture:        x86_64    ##cpu架構(gòu)
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    ##每個(gè)cpu核,只能支持2個(gè)線程.
Core(s) per socket:  8    ##每個(gè)cpu,有8個(gè)核
Socket(s):           1     ##總共有1個(gè)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、查看內(nèi)存信息

$ free -h

查詢結(jié)果如下:內(nèi)存為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 

查詢結(jié)果如下:磁盤存儲500G

[root@06 ~]# fdisk -l 
Disk /dev/vda: 500 GiB, 536870912000 bytes, 1048576000 sectors   #表示這是一個(gè)名為/dev/vda的硬盤,總?cè)萘繛?00 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、操作命令如下,本機(jī)中沒有安裝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、登錄官網(wǎng)下載

從官網(wǎng)中選擇相應(yīng)的版本,我選擇了最新的包,在聯(lián)網(wǎng)的環(huán)境下載到本地備用

https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz

五、安裝docker

1、在centos8中創(chuàng)建文件夾,執(zhí)行以下命令

$ mkdir /data/iot     #這里自己定義文件夾的名稱

結(jié)果如下:

[root@06 iot]# pwd
/data/iot

2、把下載的 docker-24.0.6.tgz 上傳到/data/iot 文件夾中,可以通過FinalShell工具

結(jié)果如下:

[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

執(zhí)行結(jié)果如下:

[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、復(fù)制docker目錄下的文件到/usr/bin目錄下

查看解壓后的目錄,我們可以發(fā)現(xiàn)都是一些可以執(zhí)行文件,我們將這些文件全部復(fù)制到/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

執(zhí)行命令

[root@06 iot]# pwd
/data/iot
[root@06 iot]# cp docker/* /usr/bin/

5、創(chuàng)建docker.service文件

進(jìn)入到/usr/lib/systemd/system/目錄下,我們編輯創(chuàng)建docker.service文件,用于管理docker服務(wù),復(fù)制黏貼如下內(nèi)容即可。

$ vim /usr/lib/systemd/system/docker.service

復(fù)制粘貼以下內(nèi)容,進(jìn)行保存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
            

執(zhí)行操作如下

[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

七、 啟動(dòng)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

九、結(jié)束

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容