關(guān)于如何使用docker部署centos系統(tǒng)測試環(huán)境
一、檢查本地服務(wù)器系統(tǒng)版本
[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狀態(tài)
[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
五、創(chuàng)建centos容器
1.運(yùn)行cnentos容器
[root@node ~]# docker run -it --name centos_test centos:7 /bin/bash [root@db4f4dfa3a84 /]#
2.進(jìn)入容器內(nèi)
[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容器內(nèi)部測試
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.查看容器內(nèi)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.測試與宿主機(jī)網(wǎng)絡(luò)連通情況
[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容器后臺運(yùn)行
從容器退出,但不停止容器: 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
到此這篇關(guān)于關(guān)于如何使用docker部署centos系統(tǒng)測試環(huán)境的文章就介紹到這了,更多相關(guān)docker部署centos系統(tǒng)環(huán)境內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
docker 容器添加指定網(wǎng)絡(luò)地址的方法實(shí)現(xiàn)
Docker容器運(yùn)行的時(shí)候默認(rèn)會自動(dòng)分配一個(gè)默認(rèn)網(wǎng)橋所在網(wǎng)段的IP地址,本文主要介紹了docker容器添加指定網(wǎng)絡(luò)地址的方法實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2024-01-01詳解docker私有倉庫搭建與使用實(shí)戰(zhàn)
這篇文章主要介紹了詳解docker私有倉庫搭建與使用實(shí)戰(zhàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-02-02Docker數(shù)據(jù)管理與網(wǎng)絡(luò)通信的使用
這篇文章主要介紹了Docker數(shù)據(jù)管理與網(wǎng)絡(luò)通信的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11Docker部署Laravel應(yīng)用實(shí)現(xiàn)隊(duì)列&任務(wù)調(diào)度
這篇文章主要介紹了Docker部署Laravel應(yīng)用實(shí)現(xiàn)隊(duì)列&任務(wù)調(diào)度,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09在Docker中安裝Oracle數(shù)據(jù)庫超詳細(xì)步驟
oracle作為全球最強(qiáng)大的關(guān)系型數(shù)據(jù)庫,應(yīng)用在各行各業(yè),下面這篇文章主要給大家介紹了關(guān)于在Docker中安裝Oracle數(shù)據(jù)庫的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-01-01win7環(huán)境下Docker快速構(gòu)建及阿里云容器加速配置詳解
這篇文章主要介紹了win7環(huán)境下Docker快速構(gòu)建及阿里云容器加速配置詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09Docker安裝部署neo4j的實(shí)戰(zhàn)過程
Docker是一種容器化技術(shù),可以在Linux系統(tǒng)上部署應(yīng)用程序,下面這篇文章主要給大家介紹了關(guān)于Docker安裝部署neo4j的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05