获取镜像

[root@localhost ~]# docker pull centos

查看镜像信息

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              latest              9baab0af79c4        8 days ago          196.7 MB

搜寻镜像

[root@localhost ~]# docker search centos

使用docker search命令搜寻远端仓库中共享的镜像


启动容器

[root@localhost ~]# docker run -it centos /bin/bash
  1. -i表示让容器的标准输入打开
  2. -t表示分配一个伪终端
  3. 要把-i -t 放到镜像名字前面
[root@db70bb3f6068 /]#
[root@db70bb3f6068 /]# ls
anaconda-post.log  dev  home  lib64       media  opt   root  sbin  sys  usr
bin                etc  lib   lost+found  mnt    proc  run   srv   tmp  var
[root@db70bb3f6068 /]# exit
exit
[root@localhost ~]#
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
db70bb3f6068        centos              "/bin/bash"         3 minutes ago       Exited (0) About a minute ago                       serene_wright

docker ps -a命令显示所有容器,会把未运行的容器也列出来


删除镜像
docker rmi IMAGE,其中IMAGE可以为标签或ID