CentOS6.5安裝Docker

這裏是用CnetOS6.5系統linux

開始安裝daoker之旅:
 
[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 \mdocker

注意其餘的源可能致使你的內核和docker的版本不一致,須要升級內核至3.x。
 
安裝:shell

[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-6ubuntu

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

啓動並設置開機自動啓動bash

[root@localhost ~]# service docker start
Starting cgconfig service:                                [肯定]
Starting docker:                                      [肯定]
[root@localhost ~]# chkconfig docker onui

獲取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
 spa

#官方安裝方式docker pull imagename從docker的索引中心下載,imagename是鏡像名稱,例如docker pull Ubuntu就是下載base ubuntu而且tag是latest。操作系統

咱們還能夠搜索基於 Fedora 和 Ubuntu 操做系統的容器。

[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

運行docker運行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 就能夠 
 
經常使用命令

總結一下經常使用命令:

其中<>闊起來的參數爲必選,[]闊起來爲可選 

  • docker version 查看docker的版本號,包括客戶端、服務端、依賴的Go等

  • docker info 查看系統(docker)層面信息,包括管理的images, containers數等

  • docker search  在docker index中搜索image

  • docker pull  從docker registry server 中下拉image

  • docker push  推送一個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 默認顯示正在運行中的container

  • docker ps -l 顯示最後一次建立的container,包括未運行的

  • docker ps -a 顯示全部的container,包括未運行的

  • docker logs  查看container的日誌,也就是執行命令的一些輸出

  • docker rm  刪除一個或多個container

  • docker rm `docker ps -a -q` 刪除全部的container

  • docker ps -a -q | xargs docker rm 同上, 刪除全部的container

  • docker rmi  刪除一個或多個image

  • docker start/stop/restart  開啓/中止/重啓container

  • docker start -i  啓動一個container並進入交互模式

  • docker attach  attach一個運行中的container

  • docker run  使用image建立container並執行相應命令,而後中止

  • docker run -i -t  /bin/bash 使用image建立container並進入交互模式, login shell是/bin/bash

  • docker run -i -t -p  將container的端口映射到宿主機的端口

  • docker commit  [repo:tag] 將一個container固化爲一個新的image,後面的repo:tag可選

  • docker build

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

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

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

  • docker port  查看本地哪一個端口映射到container的指定端口,其實用docker ps 也能夠看到

CentOS 6/7系列安裝Docker http://www.linuxidc.com/Linux/2014-07/104768.htm

Docker的搭建Gitlab CI 全過程詳解 http://www.linuxidc.com/Linux/2013-12/93537.htm

Docker安裝應用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm

在 Docker 中使用 MySQL http://www.linuxidc.com/Linux/2014-01/95354.htm

在Ubuntu Trusty 14.04 (LTS) (64-bit)安裝Docker http://www.linuxidc.com/Linux/2014-10/108184.htm

Docker安裝應用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm

Ubuntu 14.04安裝Docker  http://www.linuxidc.com/linux/2014-08/105656.htm

阿里雲CentOS 6.5 模板上安裝 Docker http://www.linuxidc.com/Linux/2014-11/109107.htm

Docker 的詳細介紹請點這裏
Docker 的下載地址請點這裏

本文永久更新連接地址http://www.linuxidc.com/Linux/2015-01/111091.htm 

相關文章
相關標籤/搜索