[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 \mlinux
注意其餘的源可能致使你的內核和docker的版本不一致,須要升級內核至3.x。
安裝:docker
[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-6shell
[root@localhost ~]# yum -y install docker-ioubuntu
啓動並設置開機自動啓動centos
[root@localhost ~]# service docker start
Starting cgconfig service: [肯定]
Starting docker: [肯定]
[root@localhost ~]# chkconfig docker onbash
獲取cnetos鏡像ui
[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是鏡像名稱,例如docker pull Ubuntu就是下載base ubuntu而且tag是latest。rest
咱們還能夠搜索基於 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 就能夠
經常使用命令
總結一下經常使用命令:
其中<>闊起來的參數爲必選,[]闊起來爲可選