1、安装docker

[root@c741 ~]# yum install docker-ce

 

2、启动服务

[root@c741 ~]# systemctl enable docker.service

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

 

[root@c741 ~]# systemctl start docker.service

 

3、配置镜像源

配置中科大的镜像源,没有文件新建文件

[root@c741 ~]# vi /etc/docker/daemon.json 

{

    "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]

}

 

也可以配置163或则阿里云的源

163的源如下所示

daemon.json

 

{

    "registry-mirrors": ["http://hub-mirror.c.163.com"]

}

 

4、测试运行hello-world 

[root@c741 docker]# docker run hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

1b930d010525: Pull complete 

Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e

Status: Downloaded newer image for hello-world:latest

 

Hello from Docker!

This message shows that your installation appears to be working correctly.

.....

 

5、查看并删除镜像

查看镜像

[root@c741 ~]# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

hello-world         latest              fce289e99eb9        3 months ago        1.84kB

 

删除镜像

[root@c741 ~]# docker rmi fce289e99eb9

Untagged: hello-world:latest

Untagged: hello-world@sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e

Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e

Deleted: sha256:af0b15c8625bb1938f1d7b17081031f649fd14e6b233688eea3c5483994a66a3

 

参考:

https://www.runoob.com/docker/docker-tutorial.html