成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

SpringCloud(第 052 篇)CentOS7 安裝 Docker 以及常用操作命令講解

suxier / 1527人閱讀

摘要:第篇安裝以及常用操作命令講解一大致介紹本章節(jié)主要帶入大家初步進入,體驗一下的安裝步驟以及操作命令。

SpringCloud(第 052 篇)CentOS7 安裝 Docker 以及常用操作命令講解

-

一、大致介紹
本章節(jié)主要帶入大家初步進入 Docker,體驗一下docker的安裝步驟以及操作命令。
二、安裝步驟 2.1 Docker環(huán)境部署要求
1、Docker 需要運行在 64-bit 的操作系統(tǒng)上并且要求Linux 內(nèi)核版本不小于 3.10,OS7滿足這個要求;
2、其余低版本的可以使用yum update 命令對操作系統(tǒng)內(nèi)核進行升級! 
3、系統(tǒng)內(nèi)核版本查看命令:uname -r

[root@svr01 ~]# uname -r
3.10.0-514.6.2.el7.x86_64
2.2 yum 命令安裝 Docker
[root@svr01 ~]# yum -y install docker

安裝完了會看到如下的打印信息:
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 檢測 Docker 是否安裝成功
[root@svr01 ~]# docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

打印該信息說明docker已經(jīng)安裝了,只是沒有啟動docker而已;
2.4 啟動 docker 后臺服務(wù)
[root@svr01 ~]# service docker start
Redirecting to /bin/systemctl start  docker.service
2.5 查看 docker 的一些相關(guān)信息
1、查看鏡像列表
[root@svr01 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

2、查看運行的鏡像列表
[root@svr01 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2.6 測試下載 hello-world 鏡像,本地沒有的話則會從docker.io的遠端鏡像庫下載
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               NAMES
2.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/centos
2.9 運行剛剛下載的 docker.io/centos 鏡像
[root@svr01 ~]# docker run -i -t docker.io/centos /bin/bash
[root@9f053696bedb /]#

1、運行 docker run 命令后會看到已經(jīng)進入的鏡像文件內(nèi)部,因此會看到 [root@9f053696bedb /]# 這樣的命令展示信息。

2、進入鏡像隨便使用看看
[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ù)說明:
    -a stdin: 指定標準輸入輸出內(nèi)容類型,可選 STDIN/STDOUT/STDERR 三項;
    -d: 后臺運行容器,并返回容器ID;
    -i: 以交互模式運行容器,通常與 -t 同時使用;
    -t: 為容器重新分配一個偽輸入終端,通常與 -i 同時使用;
    --name="nginx-lb": 為容器指定一個名稱;
    --dns 8.8.8.8: 指定容器使用的DNS服務(wù)器,默認和宿主一致;
    --dns-search example.com: 指定容器DNS搜索域名,默認和宿主一致;
    -h "mars": 指定容器的hostname;
    -e username="ritchie": 設(shè)置環(huán)境變量;
    --env-file=[]: 從指定文件讀入環(huán)境變量;
    --cpuset="0-2" or --cpuset="0,1,2": 綁定容器到指定CPU運行;
    -m :設(shè)置容器使用內(nèi)存最大值;
    --net="bridge": 指定容器的網(wǎng)絡(luò)連接類型,支持 bridge/host/none/container: 四種類型;
    --link=[]: 添加鏈接到另一個容器;
    --expose=[]: 開放一個端口或一組端口;
2.10 在 docker.io/centos 鏡像中隨便裝個東西,舉例裝個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.out
2.11 針對已經(jīng)安裝json的docker.io/centos鏡像庫打包,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 kB
2.12 給剛剛打包的 docker.io/centos:v2 鏡像設(shè)置鏡像標簽
[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 kB
2.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 kB
2.14 刪除單個已經(jīng)停止的容器
[root@svr01 ~]# docker rm 47de3399a0ab
47de3399a0ab

[root@svr01 ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2.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               NAMES
2.16 殺掉單個正在執(zhí)行的容器
[root@svr01 ~]# docker kill 47de3399a0ab
47de3399a0ab

[root@svr01 ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2.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               NAMES
2.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.gz
2.19 將磁盤的鏡像文件導(dǎo)入到docker中,并且通過 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             SIZE
                                               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
2.20 驗證剛剛加載的鏡像能否成功運行,能進入的話,并且成功exit則導(dǎo)入成功
[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)注,您的肯定是對我最大的支持!!!

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/70818.html

相關(guān)文章

  • SpringCloud 052 CentOS7 安裝 Docker 以及常用操作命令講解

    摘要:第篇安裝以及常用操作命令講解一大致介紹本章節(jié)主要帶入大家初步進入,體驗一下的安裝步驟以及操作命令。 SpringCloud(第 052 篇)CentOS7 安裝 Docker 以及常用操作命令講解 - 一、大致介紹 本章節(jié)主要帶入大家初步進入 Docker,體驗一下docker的安裝步驟以及操作命令。 二、安裝步驟 2.1 Docker環(huán)境部署要求 1、Docker 需要運行在 64-...

    jubincn 評論0 收藏0
  • SpringCloud 053 CentOS7 中用 Docker 部署一個簡單的基于 Eu

    摘要:第篇中用部署一個簡單的基于服務(wù)治理發(fā)現(xiàn)的項目一大致介紹糾結(jié)了一下下,這么簡單的部署流程是否需要詳細的貼出來,然而糾結(jié)了一下還是將這個簡單的部署流程補充完整了經(jīng)過上節(jié)的講解,相信大家已經(jīng)對的命令操作都有了一定的了解,這里我就暫且默認大家都擁 SpringCloud(第 053 篇)CentOS7 中用 Docker 部署一個簡單的基于 Eureka 服務(wù)治理發(fā)現(xiàn)的項目 - 一、大致介紹 ...

    mgckid 評論0 收藏0
  • SpringCloud 053 CentOS7 中用 Docker 部署一個簡單的基于 Eu

    摘要:第篇中用部署一個簡單的基于服務(wù)治理發(fā)現(xiàn)的項目一大致介紹糾結(jié)了一下下,這么簡單的部署流程是否需要詳細的貼出來,然而糾結(jié)了一下還是將這個簡單的部署流程補充完整了經(jīng)過上節(jié)的講解,相信大家已經(jīng)對的命令操作都有了一定的了解,這里我就暫且默認大家都擁 SpringCloud(第 053 篇)CentOS7 中用 Docker 部署一個簡單的基于 Eureka 服務(wù)治理發(fā)現(xiàn)的項目 - 一、大致介紹 ...

    Enlightenment 評論0 收藏0
  • paascloud開源項目學(xué)習(xí)(2) -- centos7安裝SpringCloud+Vue環(huán)境

    摘要:依次執(zhí)行下面命令本地安裝從官方安裝包下載。管理界面提供多種管理方式命令行和界面等提供一個開源的擴展項目里面包含一個子項目配置下打個包就可以用了。 前言 github 開源項目--paascloud-master:https://github.com/paascloud/... paascloud-master 官方環(huán)境搭建:http://blog.paascloud.net/20...

    jsdt 評論0 收藏0
  • SpringCloud 055 CentOS7 搭建 docker-registry 私有庫

    摘要:第篇搭建私有庫及管理界面一大致介紹基于前面的部署,容器一多非常不便于管理,于是急需一個自己的私有庫而目前市面上大多數(shù)的私有庫基本上都是后臺服務(wù)加前臺構(gòu)成,于是選來選去,最后選擇了管理界面之所以選擇這款管理界面,我就簡述闡述一下,基于以下 SpringCloud(第 055 篇)CentOS7 搭建 docker-registry 私有庫及管理界面 - 一、大致介紹 1、基于前面dock...

    tracymac7 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<