1.查看当前系统中的容器列表

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
1ce9f640478d        ubuntu:latest       "/bin/bash"         5 minutes ago       Exited (0) 14 seconds ago                       ovcer_the_container  
8c342c0c275c        ubuntu:latest       "/bin/bash"         51 minutes ago      Exited (0) 31 minutes ago                       sharp_bohr      

 

2.重新启动一个容器

[root@localhost ~]# docker start ovcer_the_container
ovcer_the_container

 

3.查看该容器是否启动成功
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1ce9f640478d        ubuntu:latest       "/bin/bash"         6 minutes ago       Up 7 seconds                            ovcer_the_container       

 

4.使用该容器

     由于Docker容器重新启动的时候,会使用docker run命令时指定的参数运行,所以容器重新启动后会运行一个交互式的会话shell.那么我们如何使用这个交互式的shell呢?可以使用下列命令

[root@localhost ~]# docker attach ovcer_the_container
root@1ce9f640478d:/#