文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

关于如何使用docker部署centos系统测试环境

2023-05-14 05:42

关注

一、检查本地服务器系统版本

[root@node ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@node ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core) 

二、检查docker版本

[root@node ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:03:33 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

三、检查docker状态

[root@node ~]# 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 Fri 2022-11-04 09:12:32 CST; 18h ago
     Docs: https://docs.docker.com
 Main PID: 10162 (dockerd)
    Tasks: 62
   Memory: 3.6G
   CGroup: /system.slice/docker.service
           ├─10162 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─21803 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 27217 -container-ip 172.17.0.2 -container-port 27017
           ├─21808 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 27217 -container-ip 172.17.0.2 -container-port 27017
           ├─33495 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3548 -container-ip 172.17.0.3 -container-port 3306
           ├─33501 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3548 -container-ip 172.17.0.3 -container-port 3306
           ├─43634 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.4 -container-port 80
           ├─43640 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.17.0.4 -container-port 80
           ├─59700 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8098 -container-ip 172.17.0.5 -container-port 80
           └─59705 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8098 -container-ip 172.17.0.5 -container-port 80

Nov 04 10:00:54 node dockerd[10162]: time="2022-11-04T10:00:54.645415843+08:00" level=info msg="Attempting next endpoint for pull after ...unknown"
Nov 04 11:46:29 node dockerd[10162]: time="2022-11-04T11:46:29.261326827+08:00" level=info msg="Attempting next endpoint for pull after ...unknown"
Nov 04 11:47:04 node dockerd[10162]: time="2022-11-04T11:47:04.769147449+08:00" level=info msg="Download failed, retrying (1/5): net/htt...timeout"
Nov 04 11:51:16 node dockerd[10162]: time="2022-11-04T11:51:16.548891252+08:00" level=error msg="Not continuing with pull after error: c...anceled"
Nov 04 11:55:42 node dockerd[10162]: time="2022-11-04T11:55:42.370401579+08:00" level=info msg="ignoring event" container=ac860c2aa163e2...kDelete"
Nov 04 14:31:26 node dockerd[10162]: time="2022-11-04T14:31:26.826919720+08:00" level=warning msg="reference for unknown type: applicati...:latest"
Nov 04 14:31:27 node dockerd[10162]: time="2022-11-04T14:31:27.105606415+08:00" level=warning msg="Error persisting manifest" digest="sha256:f2e...
Nov 04 14:31:27 node dockerd[10162]: time="2022-11-04T14:31:27.105748609+08:00" level=warning msg="Image docker.io/romainlecomte/lighthttpd-dock...
Nov 04 14:45:39 node dockerd[10162]: time="2022-11-04T14:45:39.628278832+08:00" level=error msg="Not continuing with pull after error: m...unknown"
Nov 04 14:45:39 node dockerd[10162]: time="2022-11-04T14:45:39.628408475+08:00" level=error msg="Handler for POST /v1.41/images/create r...unknown"
Hint: Some lines were ellipsized, use -l to show in full.

四、下载centos镜像

[root@node ~]# docker pull centos:7
7: Pulling from library/centos
Digest: sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Status: Image is up to date for centos:7
docker.io/library/centos:7

五、创建centos容器

1.运行cnentos容器

[root@node ~]# docker run -it --name centos_test   centos:7 /bin/bash
[root@db4f4dfa3a84 /]# 

2.进入容器内

[root@node ~]# docker run -it --name centos_test   centos:7 /bin/bash
[root@db4f4dfa3a84 /]# ls
anaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@db4f4dfa3a84 /]# pwd
/

六、centos容器内部测试

1.安装ifconfig命令的软件包

[root@db4f4dfa3a84 /]# yum -y install net-tools
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                          Arch                          Version                                          Repository                   Size
===================================================================================================================================================
Installing:
 net-tools                        x86_64                        2.0-0.25.20131004git.el7                         base                        306 k

Transaction Summary
===================================================================================================================================================
Install  1 Package

Total download size: 306 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                               | 306 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                       1/1 
  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                       1/1 

Installed:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                                                                                      

Complete!

2.查看容器内IP地址

[root@db4f4dfa3a84 /]# ifconfigeth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.6 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:ac:11:00:06 txqueuelen 0 (Ethernet) RX packets 7037 bytes 25618849 (24.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4655 bytes 269171 (262.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@db4f4dfa3a84 /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.6  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:06  txqueuelen 0  (Ethernet)
        RX packets 7037  bytes 25618849 (24.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4655  bytes 269171 (262.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3.测试与宿主机网络连通情况

[root@db4f4dfa3a84 /]# ping 192.168.3.166 -c 6
PING 192.168.3.166 (192.168.3.166) 56(84) bytes of data.
64 bytes from 192.168.3.166: icmp_seq=1 ttl=64 time=0.091 ms
64 bytes from 192.168.3.166: icmp_seq=2 ttl=64 time=0.130 ms
64 bytes from 192.168.3.166: icmp_seq=3 ttl=64 time=0.104 ms
64 bytes from 192.168.3.166: icmp_seq=4 ttl=64 time=0.109 ms
64 bytes from 192.168.3.166: icmp_seq=5 ttl=64 time=0.075 ms
64 bytes from 192.168.3.166: icmp_seq=6 ttl=64 time=0.092 ms

--- 192.168.3.166 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5010ms
rtt min/avg/max/mdev = 0.075/0.100/0.130/0.018 ms

4.让centos容器后台运行

从容器退出,但不停止容器: Ctrl+P+Q

[root@node ~]# docker ps
CONTAINER ID   IMAGE                                    COMMAND                  CREATED          STATUS          PORTS                                            NAMES
db4f4dfa3a84   centos:7                                 "/bin/bash"              11 minutes ago   Up 11 minutes                                                    centos_test

到此这篇关于关于如何使用docker部署centos系统测试环境的文章就介绍到这了,更多相关docker部署centos系统环境内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-服务器
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯