国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > 如何在CentOS6.5系統(tǒng)中安裝Docker

    如何在CentOS6.5系統(tǒng)中安裝Docker

    時(shí)間: 孫勝652 分享

    如何在CentOS6.5系統(tǒng)中安裝Docker

      Docker是基于LXC的高級(jí)容量引擎,可用于目前流行的Linux系統(tǒng),啟動(dòng)快,資源占用小,下面學(xué)習(xí)啦小編就給大家介紹下CentOS6.5安裝Docker的方法,一起來(lái)學(xué)習(xí)下吧。

      開(kāi)始安裝docker之旅:

      [root@localhost ~]# uname -r

      2.6.32-431.el6.x86_64

      [root@localhost ~]# cat /etc/issue

      CentOS release 6.5 (Final)

      Kernel \r on an \m

      注意其他的源可能導(dǎo)致你的內(nèi)核和docker的版本不一致,需要升級(jí)內(nèi)核至3.x。

      安裝:

      [root@localhost ~]# rpm -ivh http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

      Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

      warning: /var/tmp/rpm-tmp.JN76fI: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

      Preparing.。。 ########################################### [100%]

      1:epel-release ########################################### [100%]

      [root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

      [root@localhost ~]# yum -y install docker-io

      啟動(dòng)并設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)

      [root@localhost ~]# service docker start

      Starting cgconfig service: [確定]

      Starting docker: [確定]

      [root@localhost ~]# chkconfig docker on

      獲取cnetos鏡像

      [root@localhost ~]# docker pull centos:latest

      centos:latest: The image you are pulling has been verified

      511136ea3c5a: Pull complete

      5b12ef8fd570: Pull complete

      34943839435d: Downloading [===》 ] 18.38 MB/232.5 MB 1h7m49s

      官方安裝方式docker pull imagename從docker的索引中心下載,imagename是鏡像名稱(chēng),例如docker pull Ubuntu就是下載base ubuntu并且tag是latest。

      我們還可以搜索基于 Fedora 和 Ubuntu 操作系統(tǒng)的容器。

      [root@localhost ~]# docker search ubuntu

      [root@localhost ~]# docker search fedora

      查看docker鏡像

      [root@localhost ~]# docker images centos

      REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

      centos latest 34943839435d Less than a second ago 224 MB

      運(yùn)行docker運(yùn)行shell

      [root@localhost ~]# docker run -i -t centos /bin/bash

      [root@2ce733141ece /]#

      [root@2ce733141ece /]#

      [root@2ce733141ece /]#

      [root@2ce733141ece /]#

      停止容器

      [root@localhost ~]# docker stop 《CONTAINER ID》

      刪除所有容器

      docker rm $(docker ps -a -q)

      查看docker的子命令,直接敲docker 或完整的docker help 就可以

      常用命令

      總結(jié)一下常用命令:

      其中《》闊起來(lái)的參數(shù)為必選,[]闊起來(lái)為可選

      docker version 查看docker的版本號(hào),包括客戶(hù)端、服務(wù)端、依賴(lài)的Go等

      docker info 查看系統(tǒng)(docker)層面信息,包括管理的images, containers數(shù)等

      docker search 在docker index中搜索image

      docker pull 從docker registry server 中下拉image

      docker push 推送一個(gè)image或repository到registry

      docker push :TAG 同上,指定tag

      docker inspect 查看image或container的底層信息

      docker images TODO filter out the intermediate image layers (intermediate image layers 是什么)

      docker images -a 列出所有的images

      docker ps 默認(rèn)顯示正在運(yùn)行中的container

      docker ps -l 顯示最后一次創(chuàng)建的container,包括未運(yùn)行的

      docker ps -a 顯示所有的container,包括未運(yùn)行的

      docker logs 查看container的日志,也就是執(zhí)行命令的一些輸出

      docker rm 刪除一個(gè)或多個(gè)container

      docker rm `docker ps -a -q` 刪除所有的container

      docker ps -a -q | xargs docker rm 同上, 刪除所有的container

      docker rmi 刪除一個(gè)或多個(gè)image

      docker start/stop/restart 開(kāi)啟/停止/重啟container

      docker start -i 啟動(dòng)一個(gè)container并進(jìn)入交互模式

      docker attach attach一個(gè)運(yùn)行中的container

      docker run 使用image創(chuàng)建container并執(zhí)行相應(yīng)命令,然后停止

      docker run -i -t /bin/bash 使用image創(chuàng)建container并進(jìn)入交互模式, login shell是/bin/bash

      docker run -i -t -p 將container的端口映射到宿主機(jī)的端口

      docker commit [repo:tag] 將一個(gè)container固化為一個(gè)新的image,后面的repo:tag可選

      docker build

      尋找path路徑下名為的Dockerfile的配置文件,使用此配置生成新的image

      docker build -t repo[:tag] 同上,可以指定repo和可選的tag

      docker build - 使用指定的dockerfile配置文件,docker以stdin方式獲取內(nèi)容,使用此配置生成新的image

      docker port 查看本地哪個(gè)端口映射到container的指定端口,其實(shí)用docker ps 也可以看到。

      上面就是CentOS6.5安裝Docker的方法介紹了,在安裝Docker的時(shí)候,需要升級(jí)內(nèi)核至3.x,以免版本不一樣,本文除了介紹Docker的安裝,還介紹了其常用的命令,希望對(duì)你有所幫助。

    317850