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

 更新时间:2023年03月31日 14:24:24   作者:江湖有缘  
这篇文章主要介绍了关于如何使用docker部署centos系统测试环境,Docker属于操作系统虚拟化技术,本文图文讲解部署过程,需要的朋友可以参考下

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

[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系统环境内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • docker使用jdk21启动jar包报错的解决方案

    docker使用jdk21启动jar包报错的解决方案

    这篇文章主要介绍了docker使用jdk21启动jar包报错的解决方案,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
    2024-07-07
  • 使用Docker部署前后端分离项目的完整步骤

    使用Docker部署前后端分离项目的完整步骤

    刚刚接触基础的运维工作,采用的是docker部署的方式,下面这篇文章主要给大家介绍了关于使用Docker部署前后端分离项目的相关资料,文中通过图文介绍的非常详细,需要的朋友可以参考下
    2023-01-01
  • Docker下Redis集群(主从+哨兵)安装配置的实现步骤

    Docker下Redis集群(主从+哨兵)安装配置的实现步骤

    本文主要介绍了Docker下Redis集群(主从+哨兵)安装配置的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧<BR>
    2022-07-07
  • Docker部署搭建WebDav服务的详细过程

    Docker部署搭建WebDav服务的详细过程

    这篇文章主要介绍了Docker部署WebDav服务,小编综合了各种共享方式后最终选择了使用 WebDav 来共享文件,下面小编把搭建部署过程分享给大家,需要的朋友可以参考下
    2022-08-08
  • 基于docker部署Oracle 19c的详细记录

    基于docker部署Oracle 19c的详细记录

    这篇文章主要介绍了基于docker部署Oracle 19c,包括拉取oracle 19c镜像、查看镜像及创建oracle 19c镜像的容器问题,结合示例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-04-04
  • Docker 教程之镜像列出详细介绍

    Docker 教程之镜像列出详细介绍

    这篇文章主要介绍了Docker 教程之镜像列出详细介绍的相关资料,需要的朋友可以参考下
    2016-12-12
  • Windows10安装WSL2 Ubuntu20.04并设置docker环境的方法

    Windows10安装WSL2 Ubuntu20.04并设置docker环境的方法

    这篇文章主要介绍了Windows10安装WSL2 Ubuntu20.04并设置docker环境的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-05-05
  • 使用Docker Swarm 搭建Wordpress的方法

    使用Docker Swarm 搭建Wordpress的方法

    这篇文章主要介绍了使用Docker Swarm 搭建Wordpress的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-05-05
  • docker打包golang应用的过程分析

    docker打包golang应用的过程分析

    这篇文章主要介绍了docker打包golang应用的过程分析,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2023-03-03
  • Docker启动常用容器命令及配置详解

    Docker启动常用容器命令及配置详解

    本文主要介绍了Docker启动常用容器命令及配置详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-03-03

最新评论