摘要:第篇安裝以及常用操作命令講解一大致介紹本章節(jié)主要帶入大家初步進(jìn)入,體驗(yàn)一下的安裝步驟以及操作命令。
SpringCloud(第 052 篇)CentOS7 安裝 Docker 以及常用操作命令講解
-
一、大致介紹本章節(jié)主要帶入大家初步進(jìn)入 Docker,體驗(yàn)一下docker的安裝步驟以及操作命令。二、安裝步驟 2.1 Docker環(huán)境部署要求
1、Docker 需要運(yùn)行在 64-bit 的操作系統(tǒng)上并且要求Linux 內(nèi)核版本不小于 3.10,OS7滿足這個(gè)要求; 2、其余低版本的可以使用yum update 命令對(duì)操作系統(tǒng)內(nèi)核進(jìn)行升級(jí)! 3、系統(tǒng)內(nèi)核版本查看命令:uname -r [root@svr01 ~]# uname -r 3.10.0-514.6.2.el7.x86_642.2 yum 命令安裝 Docker
[root@svr01 ~]# yum -y install docker 安裝完了會(huì)看到如下的打印信息: Installed: docker.x86_64 2:1.12.6-68.gitec8512b.el7.centos Dependency Installed: audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7 container-selinux.noarch 2:2.33-1.git86f33cd.el7 container-storage-setup.noarch 0:0.8.0-3.git1d27ecf.el7 device-mapper-event.x86_64 7:1.02.140-8.el7 device-mapper-event-libs.x86_64 7:1.02.140-8.el7 device-mapper-persistent-data.x86_64 0:0.7.0-0.1.rc6.el7 docker-client.x86_64 2:1.12.6-68.gitec8512b.el7.centos docker-common.x86_64 2:1.12.6-68.gitec8512b.el7.centos libcgroup.x86_64 0:0.41-13.el7 libseccomp.x86_64 0:2.3.1-3.el7 libsemanage-python.x86_64 0:2.5-8.el7 lvm2.x86_64 7:2.02.171-8.el7 lvm2-libs.x86_64 7:2.02.171-8.el7 oci-register-machine.x86_64 1:0-3.13.gitcd1e331.el7 oci-systemd-hook.x86_64 1:0.1.14-1.git1ba44c6.el7 oci-umount.x86_64 2:2.3.0-1.git51e7c50.el7 policycoreutils-python.x86_64 0:2.5-17.1.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-1.1.el7 skopeo-containers.x86_64 1:0.1.26-2.dev.git2e8377a.el7.centos yajl.x86_64 0:2.0.4-4.el7 Dependency Updated: audit.x86_64 0:2.7.6-3.el7 audit-libs.x86_64 0:2.7.6-3.el7 device-mapper.x86_64 7:1.02.140-8.el7 device-mapper-libs.x86_64 7:1.02.140-8.el7 libsemanage.x86_64 0:2.5-8.el7 policycoreutils.x86_64 0:2.5-17.1.el7 Complete!2.3 檢測(cè) Docker 是否安裝成功
[root@svr01 ~]# docker images Cannot connect to the Docker daemon. Is the docker daemon running on this host? 打印該信息說(shuō)明docker已經(jīng)安裝了,只是沒有啟動(dòng)docker而已;2.4 啟動(dòng) docker 后臺(tái)服務(wù)
[root@svr01 ~]# service docker start Redirecting to /bin/systemctl start docker.service2.5 查看 docker 的一些相關(guān)信息
1、查看鏡像列表 [root@svr01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 2、查看運(yùn)行的鏡像列表 [root@svr01 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.6 測(cè)試下載 hello-world 鏡像,本地沒有的話則會(huì)從docker.io的遠(yuǎn)端鏡像庫(kù)下載
1、下載 hello-world 鏡像 [root@svr01 ~]# docker run hello-world Unable to find image "hello-world:latest" locally Trying to pull repository docker.io/library/hello-world ... latest: Pulling from docker.io/library/hello-world ca4f61b1923c: Pull complete Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ 2、再次查看 docker 現(xiàn)有的資源: [root@svr01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB [root@svr01 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.7 搜索鏡像文件
[root@svr01 ~]# docker search centos INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/centos The official build of CentOS. 3876 [OK] docker.io docker.io/ansible/centos7-ansible Ansible on Centos7 103 [OK] docker.io docker.io/jdeathe/centos-ssh CentOS-6 6.9 x86_64 / CentOS-7 7.4.1708 x8... 90 [OK] docker.io docker.io/consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 37 [OK] docker.io docker.io/imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 34 [OK] docker.io docker.io/tutum/centos Simple CentOS docker image with SSH access 34 docker.io docker.io/gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glu... 21 [OK] docker.io docker.io/kinogmt/centos-ssh CentOS with SSH 17 [OK] docker.io docker.io/centos/python-35-centos7 Platform for building and running Python 3... 14 docker.io docker.io/openshift/base-centos7 A Centos7 derived base image for Source-To... 13 docker.io docker.io/centos/php-56-centos7 Platform for building and running PHP 5.6 ... 10 docker.io docker.io/openshift/jenkins-2-centos7 A Centos7 based Jenkins v2.x image for use... 7 docker.io docker.io/openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 ima... 6 docker.io docker.io/darksheer/centos Base Centos Image -- Updated hourly 3 [OK] docker.io docker.io/openshift/ruby-20-centos7 DEPRECATED: A Centos7 based Ruby v2.0 imag... 3 docker.io docker.io/blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK] docker.io docker.io/miko2u/centos6 CentOS6 鏃ユ湰瑾炵挵澧 1 [OK] docker.io docker.io/openshift/php-55-centos7 DEPRECATED: A Centos7 based PHP v5.5 image... 1 docker.io docker.io/pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag nam... 1 docker.io docker.io/pivotaldata/centos-mingw Using the mingw toolchain to cross-compile... 1 docker.io docker.io/jameseckersall/sonarr-centos Sonarr on CentOS 7 0 [OK] docker.io docker.io/openshift/wildfly-101-centos7 A Centos7 based WildFly v10.1 image for us... 0 docker.io docker.io/pivotaldata/centos Base centos, freshened up a little with a ... 0 docker.io docker.io/pivotaldata/centos-gcc-toolchain CentOS with a toolchain, but unaffiliated ... 0 docker.io docker.io/smartentry/centos centos with smartentry 0 [OK]2.8 拉取鏡像文件
[root@svr01 ~]# docker pull docker.io/centos2.9 運(yùn)行剛剛下載的 docker.io/centos 鏡像
[root@svr01 ~]# docker run -i -t docker.io/centos /bin/bash [root@9f053696bedb /]# 1、運(yùn)行 docker run 命令后會(huì)看到已經(jīng)進(jìn)入的鏡像文件內(nèi)部,因此會(huì)看到 [root@9f053696bedb /]# 這樣的命令展示信息。 2、進(jìn)入鏡像隨便使用看看 [root@9f053696bedb /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@9f053696bedb /]# cd /home/ [root@9f053696bedb home]# mkdir hmilyylimh [root@9f053696bedb home]# mkdir -p hmilyylimh/docker [root@9f053696bedb home]# cd hmilyylimh/docker/ [root@9f053696bedb docker]# 3、退出鏡像 [root@9f053696bedb docker]# exit exit [root@svr01 ~]# 4、參數(shù)說(shuō)明: -a stdin: 指定標(biāo)準(zhǔn)輸入輸出內(nèi)容類型,可選 STDIN/STDOUT/STDERR 三項(xiàng); -d: 后臺(tái)運(yùn)行容器,并返回容器ID; -i: 以交互模式運(yùn)行容器,通常與 -t 同時(shí)使用; -t: 為容器重新分配一個(gè)偽輸入終端,通常與 -i 同時(shí)使用; --name="nginx-lb": 為容器指定一個(gè)名稱; --dns 8.8.8.8: 指定容器使用的DNS服務(wù)器,默認(rèn)和宿主一致; --dns-search example.com: 指定容器DNS搜索域名,默認(rèn)和宿主一致; -h "mars": 指定容器的hostname; -e username="ritchie": 設(shè)置環(huán)境變量; --env-file=[]: 從指定文件讀入環(huán)境變量; --cpuset="0-2" or --cpuset="0,1,2": 綁定容器到指定CPU運(yùn)行; -m :設(shè)置容器使用內(nèi)存最大值; --net="bridge": 指定容器的網(wǎng)絡(luò)連接類型,支持 bridge/host/none/container: 四種類型; --link=[]: 添加鏈接到另一個(gè)容器; --expose=[]: 開放一個(gè)端口或一組端口;2.10 在 docker.io/centos 鏡像中隨便裝個(gè)東西,舉例裝個(gè)json
[root@svr01 ~]# docker run -i -t docker.io/centos /bin/bash [root@497905f140a6 /]# gem install json bash: gem: command not found [root@497905f140a6 /]# yum install gem 。。。。 Installed: rubygems.noarch 0:2.0.14.1-30.el7 Dependency Installed: libyaml.x86_64 0:0.1.4-11.el7_0 ruby.x86_64 0:2.0.0.648-30.el7 ruby-irb.noarch 0:2.0.0.648-30.el7 ruby-libs.x86_64 0:2.0.0.648-30.el7 rubygem-bigdecimal.x86_64 0:1.2.0-30.el7 rubygem-io-console.x86_64 0:0.4.2-30.el7 rubygem-json.x86_64 0:1.7.7-30.el7 rubygem-psych.x86_64 0:2.0.0-30.el7 rubygem-rdoc.noarch 0:4.0.0-30.el7 Complete! [root@497905f140a6 /]# gem install json Fetching: json-2.1.0.gem (100%) Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can"t find header files for ruby at /usr/share/include/ruby.h Gem files will remain installed in /usr/local/share/gems/gems/json-2.1.0 for inspection. Results logged to /usr/local/share/gems/gems/json-2.1.0/ext/json/ext/generator/gem_make.out2.11 針對(duì)已經(jīng)安裝json的docker.io/centos鏡像庫(kù)打包,tag命名為v2
[root@497905f140a6 /]# docker commit -m ="add new image" -a="hmilyylimh" 497905f140a6 docker.io/centos:v2 bash: docker: command not found [root@497905f140a6 /]# exit exit [root@svr01 ~]# docker commit -m ="add new image" -a="HEHUI231" 497905f140a6 docker.io/centos:v2 sha256:11efb35f320cec46c83bc4dcbc184c8d45dcb3e369105251d70e2336fd261c92 [root@svr01 ~]# docker images; REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 17 seconds ago 307.5 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB2.12 給剛剛打包的 docker.io/centos:v2 鏡像設(shè)置鏡像標(biāo)簽
[root@svr01 ~]# docker tag 11efb35f320c docker.io/centos:v22 [root@svr01 ~]# docker images; REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 36 minutes ago 307.5 MB docker.io/centos v22 11efb35f320c 36 minutes ago 307.5 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB2.13 刪除 docker.io/centos:v2 鏡像文件
[root@svr01 ~]# docker rmi docker.io/centos:v22 Untagged: docker.io/centos:v22 [root@svr01 ~]# docker images; REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 37 minutes ago 307.5 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB2.14 刪除單個(gè)已經(jīng)停止的容器
[root@svr01 ~]# docker rm 47de3399a0ab 47de3399a0ab [root@svr01 ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.15 刪除所有已經(jīng)停止的容器
[root@svr01 ~]# docker rm $(docker ps -a -q) ca94bd87299f 43a27d23f3ee 497905f140a6 fb9512c00a84 9f053696bedb 565b5d3e5139 9c2518ba47c8 1abaaef82836 e5b39fc724ab [root@svr01 ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.16 殺掉單個(gè)正在執(zhí)行的容器
[root@svr01 ~]# docker kill 47de3399a0ab 47de3399a0ab [root@svr01 ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.17 殺掉所有正在執(zhí)行的容器
[root@svr01 ~]# docker kill $(docker ps -q) ca94bd87299f 43a27d23f3ee 497905f140a6 fb9512c00a84 9f053696bedb 565b5d3e5139 9c2518ba47c8 1abaaef82836 e5b39fc724ab [root@svr01 ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2.18 將image文件保存到磁盤目錄
[root@svr01 ~]# docker images; REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 5 hours ago 307.5 MB docker.io/frolvlad/alpine-oraclejdk8 latest 4f03dc990224 12 days ago 170.1 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB [root@svr01 ~]# docker save 4f03dc990224 > /home/install/alpine-oraclejdk8.tar [root@svr01 ~]# ls /home/install/ alpine-oraclejdk8.tar hive MySQL-5.6.27-1.el7.x86_64.rpm-bundle.tar openssl-1.0.2l.tar.gz redis-3.2.9.tar.gz apache-flume-1.7.0-bin.tar.gz httpd-2.4.26.tar.gz mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar pcre-8.41.tar.gz zlib-1.2.11.tar.gz hadoop memcached-1.4.39.tar.gz nginx-1.12.0.tar.gz php-5.6.31.tar.gz zookeeper-3.4.10.tar.gz2.19 將磁盤的鏡像文件導(dǎo)入到docker中,并且通過(guò) docker tag 修改名稱和tag
[root@svr01 ~]# docker load < /home/install/centos-v2.tar e9613a472968: Loading layer [==================================================>] 105 MB/105 MB Loaded image ID: sha256:11efb35f320cec46c83bc4dcbc184c8d45dcb3e369105251d70e2336fd261c92 [root@svr01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE2.20 驗(yàn)證剛剛加載的鏡像能否成功運(yùn)行,能進(jìn)入的話,并且成功exit則導(dǎo)入成功11efb35f320c 5 hours ago 307.5 MB docker.io/frolvlad/alpine-oraclejdk8 latest 4f03dc990224 12 days ago 170.1 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB [root@svr01 ~]# docker tag 11efb35f320c docker.io/centos:v2 [root@svr01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 5 hours ago 307.5 MB docker.io/frolvlad/alpine-oraclejdk8 latest 4f03dc990224 12 days ago 170.1 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB
[root@svr01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/centos v2 11efb35f320c 5 hours ago 307.5 MB docker.io/frolvlad/alpine-oraclejdk8 latest 4f03dc990224 12 days ago 170.1 MB docker.io/centos latest 3fa822599e10 2 weeks ago 203.5 MB docker.io/hello-world latest f2a91732366c 3 weeks ago 1.848 kB [root@svr01 ~]# docker run -it docker.io/centos:v2 [root@0a87728d1798 /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@0a87728d1798 /]# exit exit [root@svr01 ~]#三、下載地址
https://gitee.com/ylimhhmily/SpringCloudTutorial.git
SpringCloudTutorial交流QQ群: 235322432
SpringCloudTutorial交流微信群: 微信溝通群二維碼圖片鏈接
歡迎關(guān)注,您的肯定是對(duì)我最大的支持!!!
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/70818.html
摘要:第篇安裝以及常用操作命令講解一大致介紹本章節(jié)主要帶入大家初步進(jìn)入,體驗(yàn)一下的安裝步驟以及操作命令。 SpringCloud(第 052 篇)CentOS7 安裝 Docker 以及常用操作命令講解 - 一、大致介紹 本章節(jié)主要帶入大家初步進(jìn)入 Docker,體驗(yàn)一下docker的安裝步驟以及操作命令。 二、安裝步驟 2.1 Docker環(huán)境部署要求 1、Docker 需要運(yùn)行在 64-...
摘要:第篇中用部署一個(gè)簡(jiǎn)單的基于服務(wù)治理發(fā)現(xiàn)的項(xiàng)目一大致介紹糾結(jié)了一下下,這么簡(jiǎn)單的部署流程是否需要詳細(xì)的貼出來(lái),然而糾結(jié)了一下還是將這個(gè)簡(jiǎn)單的部署流程補(bǔ)充完整了經(jīng)過(guò)上節(jié)的講解,相信大家已經(jīng)對(duì)的命令操作都有了一定的了解,這里我就暫且默認(rèn)大家都擁 SpringCloud(第 053 篇)CentOS7 中用 Docker 部署一個(gè)簡(jiǎn)單的基于 Eureka 服務(wù)治理發(fā)現(xiàn)的項(xiàng)目 - 一、大致介紹 ...
摘要:第篇中用部署一個(gè)簡(jiǎn)單的基于服務(wù)治理發(fā)現(xiàn)的項(xiàng)目一大致介紹糾結(jié)了一下下,這么簡(jiǎn)單的部署流程是否需要詳細(xì)的貼出來(lái),然而糾結(jié)了一下還是將這個(gè)簡(jiǎn)單的部署流程補(bǔ)充完整了經(jīng)過(guò)上節(jié)的講解,相信大家已經(jīng)對(duì)的命令操作都有了一定的了解,這里我就暫且默認(rèn)大家都擁 SpringCloud(第 053 篇)CentOS7 中用 Docker 部署一個(gè)簡(jiǎn)單的基于 Eureka 服務(wù)治理發(fā)現(xiàn)的項(xiàng)目 - 一、大致介紹 ...
摘要:依次執(zhí)行下面命令本地安裝從官方安裝包下載。管理界面提供多種管理方式命令行和界面等提供一個(gè)開源的擴(kuò)展項(xiàng)目里面包含一個(gè)子項(xiàng)目配置下打個(gè)包就可以用了。 前言 github 開源項(xiàng)目--paascloud-master:https://github.com/paascloud/... paascloud-master 官方環(huán)境搭建:http://blog.paascloud.net/20...
摘要:第篇搭建私有庫(kù)及管理界面一大致介紹基于前面的部署,容器一多非常不便于管理,于是急需一個(gè)自己的私有庫(kù)而目前市面上大多數(shù)的私有庫(kù)基本上都是后臺(tái)服務(wù)加前臺(tái)構(gòu)成,于是選來(lái)選去,最后選擇了管理界面之所以選擇這款管理界面,我就簡(jiǎn)述闡述一下,基于以下 SpringCloud(第 055 篇)CentOS7 搭建 docker-registry 私有庫(kù)及管理界面 - 一、大致介紹 1、基于前面dock...
閱讀 2958·2021-11-08 13:20
閱讀 1031·2021-09-22 15:20
閱讀 660·2019-08-30 15:53
閱讀 1964·2019-08-30 15:43
閱讀 1278·2019-08-29 17:21
閱讀 540·2019-08-29 12:15
閱讀 2375·2019-08-28 17:51
閱讀 3142·2019-08-26 13:26