1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      Docker容器的基礎(chǔ)操作

      概述

      Docker 是一個(gè)開源的應(yīng)用容器引擎,讓開發(fā)者可以打包他們的應(yīng)用以及依賴包到一個(gè)可移植的容器中,然后發(fā)布到任何流行的Linux機(jī)器或Windows 機(jī)器上,也可以實(shí)現(xiàn)虛擬化,容器是完全使用沙箱機(jī)制,相互之間不會(huì)有任何接口。

      大同網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),大同網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為大同數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的大同做網(wǎng)站的公司定做!

      安裝Docker

      配置阿里云base源和epel源,安裝Docker環(huán)境依賴





      [root@youxi1 ~]# cd /etc/yum.repos.d/
      [root@youxi1 yum.repos.d]# mkdir back
      [root@youxi1 yum.repos.d]# mv *.repo back/  //備份源
      [root@youxi1 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
      [root@youxi1 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
      [root@youxi1 yum.repos.d]# yum clean all  //清空yum緩存
      [root@youxi1 yum.repos.d]# yum list  //生成緩存
      [root@youxi1 yum.repos.d]# cd
      [root@youxi1 ~]# yum -y install yum-utils device-mapper-persistent-data lvm2  //安裝依賴
      [root@youxi1 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  //配置阿里云的Docker的yum源

      安裝Docker,啟動(dòng)并設(shè)置開機(jī)自啟


      [root@youxi1 ~]# yum -y install docker-ce docker-ce-cli containerd.io
      [root@youxi1 ~]# systemctl start docker
      [root@youxi1 ~]# systemctl enable docker
      Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
      [root@youxi1 ~]# docker version  //顯示Docker版本信息
      Client: Docker Engine - Community
       Version:           19.03.2
       API version:       1.40
       Go version:        go1.12.8
       Git commit:        6a30dfc
       Built:             Thu Aug 29 05:28:55 2019
       OS/Arch:           linux/amd64
       Experimental:      false
       
      Server: Docker Engine - Community
       Engine:
        Version:          19.03.2
        API version:      1.40 (minimum version 1.12)
        Go version:       go1.12.8
        Git commit:       6a30dfc
        Built:            Thu Aug 29 05:27:34 2019
        OS/Arch:          linux/amd64
        Experimental:     false
       containerd:
        Version:          1.2.6
        GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
       runc:
        Version:          1.0.0-rc8
        GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
       docker-init:
        Version:          0.18.0
        GitCommit:        fec3683
      [root@youxi1 ~]# docker info  //查看Docker信息,包括鏡像和容器數(shù)
      Client:
       Debug Mode: false
       
      Server:
       Containers: 0  //容器
        Running: 0  //運(yùn)行
        Paused: 0  //暫停
        Stopped: 0  //關(guān)閉
       Images: 0  //鏡像
       Server Version: 19.03.2  //版本
       Storage Driver: overlay2  //存儲(chǔ)啟動(dòng)程序
        Backing Filesystem: xfs  //備份文件系統(tǒng)格式
        Supports d_type: true
        Native Overlay Diff: true
       Logging Driver: json-file
       Cgroup Driver: cgroupfs
       Plugins:
        Volume: local
        Network: bridge host ipvlan macvlan null overlay
        Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
       Swarm: inactive
       Runtimes: runc
       Default Runtime: runc
       Init Binary: docker-init
       containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
       runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
       init version: fec3683
       Security Options:
        seccomp
         Profile: default
       Kernel Version: 3.10.0-862.el7.x86_64
       Operating System: CentOS Linux 7 (Core)
       OSType: linux
       Architecture: x86_64
       CPUs: 4
       Total Memory: 1.936GiB
       Name: youxi1
       ID: FR4U:DHB6:QGST:B3SB:NHKD:GDBX:PZL3:2RSX:SUMM:WFZO:KPPU:W423
       Docker Root Dir: /var/lib/docker  //Docker的主目錄
       Debug Mode: false
       Registry: https://index.docker.io/v1/
       Labels:
       Experimental: false
       Insecure Registries:
        127.0.0.0/8
       Live Restore Enabled: false

      一、查看本地容器進(jìn)程

      [root@docker ~]# docker ps -a     #顯示所有容器進(jìn)程
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                    PORTS               NAMES
      9bd32b3b2ad0        hello-world         "/hello"            20 hours ago        Exited (0) 20 hours ago                       lucid_murdock
      fb2d81c98cd2        hello-world         "/hello"            3 weeks ago         Exited (0) 3 weeks ago                        great_bartik
      [root@docker ~]# docker ps          #顯示當(dāng)前運(yùn)行的容器進(jìn)程
      CONTAINER ID        IMAGE   

      二、容器啟動(dòng)命令

      [root@docker ~]# docker run --help
      Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
      OPTIONS:選項(xiàng)
      -i : 表示啟動(dòng)一個(gè)可交互的容器,并持續(xù)打開標(biāo)準(zhǔn)輸入
      -t : 表示使用終端關(guān)聯(lián)到容器的標(biāo)準(zhǔn)輸入輸出上
      -d : 表示將容器放置后臺(tái)運(yùn)行
      --rm : 退出后即刪除容器
      --name : 表示定義容器唯一名稱
      IMAGE: 表示要運(yùn)行的鏡像
      COMMAND : 表示啟動(dòng)容器時(shí)運(yùn)行的命令

      三、啟動(dòng)一個(gè)交互式的容器

      [root@docker ~]# docker images
      REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
      alpine                latest              cc0abc535e36        13 days ago         5.59MB
      zhoumingkang/alpine   v3.10.3             cc0abc535e36        13 days ago         5.59MB
      alpine                3.9.4               055936d39205        8 months ago        5.53MB
      hello-world           latest              fce289e99eb9        12 months ago       1.84kB
      [root@docker ~]# docker run -ti -- name mingkang-test alpine:latest /bin/sh
      / # ip addr
      1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
      18: eth0@if19:  mtu 1500 qdisc noqueue state UP 
          link/ether 02:42:ac:07:05:02 brd ff:ff:ff:ff:ff:ff
          inet 172.7.5.2/24 brd 172.7.5.255 scope global eth0
             valid_lft forever preferred_lft forever
      / # cat /etc/issue 
      Welcome to Alpine Linux 3.11
      Kernel \r on an \m (\l)
      
      [root@docker ~]# docker ps      #查看當(dāng)前運(yùn)行的容器進(jìn)程
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
      08b02f026afe        alpine:latest       "/bin/sh"           7 seconds ago       Up 5 seconds                            mingkang-test

      四、容器退出后即刪除--rm(docker ps -a 查詢不了記錄)

      [root@docker ~]# docker run --rm alpine:latest /bin/echo hello
      hello

      五、以后臺(tái)的形式運(yùn)行一個(gè)容器-d

      [root@docker ~]# docker run -d --name mingkang-test3 alpine:latest /bin/sleep 3000
      744b31fbaadfc9605d5dbe8d302ef9bd3de8208142aa00c1feffd86804347b01
      [root@docker ~]# docker ps
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
      744b31fbaadf        alpine:latest       "/bin/sleep 3000"   18 seconds ago      Up 17 seconds                           mingkang-test3

      六、進(jìn)入一個(gè)容器exec

      [root@docker ~]# docker exec -ti 744b31fbaadf /bin/sh      #長(zhǎng)長(zhǎng)的字符串為容器ID
      / # ps
      PID   USER     TIME  COMMAND
          1 root      0:00 /bin/sleep 3000
          6 root      0:00 /bin/sh
         11 root      0:00 ps
      / # 

      七、停止/重啟/啟動(dòng)一個(gè)容器(stop/restart/start)

      [root@docker ~]# docker ps
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
      744b31fbaadf        alpine:latest       "/bin/sleep 3000"   3 minutes ago       Up 3 minutes                            mingkang-test3
      [root@docker ~]# docker stop 744b31fbaadf    #容器的ID號(hào)
      744b31fbaadf
      [root@docker ~]# docker ps
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

      八、刪除docker ps 的內(nèi)容

      [root@docker ~]# docker ps -a
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                        PORTS               NAMES
      744b31fbaadf        alpine:latest       "/bin/sleep 3000"   12 minutes ago      Exited (137) 8 minutes ago                        mingkang-test3
      08b02f026afe        alpine:latest       "/bin/sh"           25 minutes ago      Exited (0) 23 minutes ago                         mingkang-test
      56760413d596        alpine:latest       "/bin/sh"           28 minutes ago      Exited (0) 27 minutes ago                         mingkang_test
      eae500caa715        alpine:latest       "/bin/sh"           34 minutes ago      Exited (0) 29 minutes ago                         vigilant_boyd
      c6fed43d8a09        alpine:latest       "/bin/sh"           34 minutes ago      Exited (0) 34 minutes ago                         keen_volhard
      058aee8ef1eb        alpine:latest       "/bin/sh"           36 minutes ago      Exited (0) 35 minutes ago                         quirky_morse
      6d81bca654ab        alpine:latest       "/bin/sh"           37 minutes ago      Exited (127) 36 minutes ago                       practical_torvalds
      adc1a16a7bf6        alpine:latest       "/bin/sh"           39 minutes ago      Exited (0) 38 minutes ago                         unruffled_carson
      20a5432e3266        alpine:latest       "/bin/sh"           39 minutes ago      Exited (0) 39 minutes ago                         elated_ellis
      08bbe9c13d26        alpine:latest       "/bin/sh"           40 minutes ago      Exited (0) 40 minutes ago                         nifty_kalam
      9bd32b3b2ad0        hello-world         "/hello"            21 hours ago        Exited (0) 21 hours ago                           lucid_murdock
      fb2d81c98cd2        hello-world         "/hello"            3 weeks ago         Exited (0) 3 weeks ago                            great_bartik
      [root@docker ~]# docker rm keen_volhard quirky_morse practical_torvalds unruffled_carson elated_ellis  nifty_kalam  lucid_murdock great_bartik
      keen_volhard
      quirky_morse
      practical_torvalds
      unruffled_carson
      elated_ellis
      nifty_kalam
      lucid_murdock
      great_bartik
      [root@docker ~]# docker ps -a
      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES
      744b31fbaadf        alpine:latest       "/bin/sleep 3000"   13 minutes ago      Exited (137) 9 minutes ago                       mingkang-test3
      08b02f026afe        alpine:latest       "/bin/sh"           26 minutes ago      Exited (0) 24 minutes ago                        mingkang-test
      56760413d596        alpine:latest       "/bin/sh"           28 minutes ago      Exited (0) 28 minutes ago                        mingkang_test
      
      備注:如需刪除在運(yùn)行的容器,使用docker rm -f 容器名稱/容器ID
      循環(huán)全部刪除:
      for i in `docker ps -a | grep -i exited|awk '{print $1}'`;do docker rm -f $i;done

      九、容器的提交(把已寫入內(nèi)容的容器提交為鏡像)

      [root@docker ~]# docker run -d --name myalpine alpine:latest /bin/sleep 30000   #后臺(tái)長(zhǎng)時(shí)間運(yùn)行一個(gè)容器
      3ccd27be4d19a60f317d187ee99d7fcd76d368dccb0326f8789d6617fb39f457
      [root@docker ~]# docker ps    #查看運(yùn)行的容器
      CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS               NAMES
      3ccd27be4d19        alpine:latest       "/bin/sleep 30000"   6 seconds ago       Up 4 seconds                            myalpine
      [root@docker ~]# docker exec -ti myalpine /bin/sh    #以交互的方式進(jìn)入容器
      / # ls
      bin    dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    tmp    usr    var
      / # touch hello.txt
      / # echo "hello world" > hello.txt 
      / # cat hello.txt 
      hello world
      [root@docker ~]# docker commit -p myalpine myalpine:latest_with_hello.txt
      #把名稱為myalpine的容器提交為一個(gè)新的鏡像
      sha256:3ce9b8b899ba2018c01ca88fba6c24da6ff1287905a4ff4c60e968f129a22863
      [root@docker ~]# docker images
      REPOSITORY            TAG                     IMAGE ID            CREATED             SIZE
      myalpine              latest_with_hello.txt   3ce9b8b899ba        20 seconds ago      5.59MB
      alpine                latest                  cc0abc535e36        13 days ago         5.59MB
      zhoumingkang/alpine   v3.10.3                 cc0abc535e36        13 days ago         5.59MB
      alpine                3.9.4                   055936d39205        8 months ago        5.53MB
      hello-world           latest                  fce289e99eb9        12 months ago       1.84kB
      
      #啟動(dòng)該myalpin:latest_with_hello.txt 鏡像容器后,發(fā)現(xiàn)文件已經(jīng)存在。

      十、容器的導(dǎo)出與加載

      導(dǎo)出myalpine:latest_with_hello.txt
      -----
      [root@docker ~]# docker images
      REPOSITORY            TAG                     IMAGE ID            CREATED             SIZE
      myalpine              latest_with_hello.txt   3ce9b8b899ba        20 minutes ago      5.59MB
      alpine                latest                  cc0abc535e36        13 days ago         5.59MB
      zhoumingkang/alpine   v3.10.3                 cc0abc535e36        13 days ago         5.59MB
      alpine                3.9.4                   055936d39205        8 months ago        5.53MB
      hello-world           latest                  fce289e99eb9        12 months ago       1.84kB
      [root@docker ~]# docker save myalpine:latest_with_hello.txt > myalpine-latest_with_hello.txt.tar
      [root@docker ~]# ls
      anaconda-ks.cfg  myalpine-latest_with_hello.txt.tar
      -----
      刪除剛剛導(dǎo)出的鏡像
      [root@docker ~]# docker rmi myalpine:latest_with_hello.txt
      Untagged: myalpine:latest_with_hello.txt
      Deleted: sha256:3ce9b8b899ba2018c01ca88fba6c24da6ff1287905a4ff4c60e968f129a22863
      Deleted: sha256:1d89a6f64295ef6889fef9ae917281e94d4d9e5c9b3eb98d5cc25c129f34f4b3
      [root@docker ~]# docker images
      REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
      alpine                latest              cc0abc535e36        13 days ago         5.59MB
      zhoumingkang/alpine   v3.10.3             cc0abc535e36        13 days ago         5.59MB
      alpine                3.9.4               055936d39205        8 months ago        5.53MB
      hello-world           latest              fce289e99eb9        12 months ago       1.84kB
      -----
      重新加載該鏡像
      [root@docker ~]# docker load < myalpine-latest_with_hello.txt.tar 
      e63a9b4f5484: Loading layer [==================================================>]  3.584kB/3.584kB
      Loaded image: myalpine:latest_with_hello.txt
      [root@docker ~]# docker images
      REPOSITORY            TAG                     IMAGE ID            CREATED             SIZE
      myalpine              latest_with_hello.txt   3ce9b8b899ba        22 minutes ago      5.59MB
      alpine                latest                  cc0abc535e36        13 days ago         5.59MB
      zhoumingkang/alpine   v3.10.3                 cc0abc535e36        13 days ago         5.59MB
      alpine                3.9.4                   055936d39205        8 months ago        5.53MB
      hello-world           latest                  fce289e99eb9        12 months ago       1.84kB

      十一、容器的日志查看

      [root@docker ~]# docker run hello-world:latest     #運(yùn)行一個(gè)容器
      
      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://hub.docker.com/
      
      For more examples and ideas, visit:
       https://docs.docker.com/get-started/
      
      [root@docker ~]# docker ps -a | grep -i hello      #查看曾經(jīng)運(yùn)行的進(jìn)程
      1c5c26a209d4        hello-world:latest   "/hello"            12 seconds ago      Exited (0) 10 seconds ago                       angry_ellis
      [root@docker ~]# docker logs 1c5c26a209d4       #查看該容器運(yùn)行的日志
      
      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://hub.docker.com/
      
      For more examples and ideas, visit:
       https://docs.docker.com/get-started/
      
      [root@docker ~]# 


      文章標(biāo)題:Docker容器的基礎(chǔ)操作
      文章地址:http://www.ef60e0e.cn/article/ispspi.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        都兰县| 隆回县| 斗六市| 北碚区| 福州市| 刚察县| 开远市| 六枝特区| 青神县| 丰宁| 永顺县| 榆林市| 隆子县| 蛟河市| 清镇市| 鄯善县| 张家界市| 萝北县| 八宿县| 庐江县| 柳州市| 定安县| 乌兰浩特市| 陈巴尔虎旗| 田林县| 洛川县| 剑川县| 兴文县| 伊春市| 东源县| 广灵县| 上高县| 乐平市| 肃宁县| 常德市| 颍上县| 涡阳县| 襄垣县| 林芝县| 明溪县| 璧山县|