安装docker

安装docker

centos6.5:
#rpm -ivh http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
#yum -y install docker-io
#yum upgrade device-mapper-libs

centos7:
#uname -r
3.10.0-514.el7.x86_64
第一步:更新当前软件:
#yum update
第二步:添加Docker的yum源
#cat /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
第三步:安装Docker
#yum install docker-engine

启动docker

#service docker start
或:
#systemctl start docker

验证Docker是否安装成功
#docker run --rm hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete 
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Status: Downloaded newer image for hello-world:latest

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.
 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/

常用操作

查看版本;
#docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
OS/Arch (server): linux/amd64

获取cnetos镜像
#docker pull centos:latest
从docker.io中下载centos镜像到本地 /var/lib/docker/graph

查看docker镜像
#docker images centos

docker运行shell
#docker run -i -t centos /bin/bash

查看所有容器(包括正在运行和已停止的)
#docker ps -a
停止容器
#docker stop
删除所有容器
#docker rm $(docker ps -a -q)

开启一个容器
#docker start container

卸载docker

列出你安装过的包

#yum list installed | grep docker
docker-engine.x86_64 1.7.1-1.el7 @/docker-engine-1.7.1-1.el7.x86_64.rpm
删除安装包
#yum -y remove docker-engine.x86_64
删除镜像/容器等
#rm -rf /var/lib/docker
rm: cannot remove `/var/lib/docker/devicemapper’: Device or resource busy
#umount /var/lib/docker/devicemapper
#rm -rf /var/lib/docker

你可能感兴趣的:(安装docker)