以下操作基于上一篇所述容器
地址:https://my.oschina.net/xiaozhiwen/blog/1600659
1、查看运行中的容器
docker ps
root@kobe:/opt/software/docker/spring-boot-docker/target# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ecf2637f10b cloudcomb/sun:1.0 "java -jar /app.jar" 45 seconds ago Up 2 seconds 0.0.0.0:1024->8080/tcp goofy_easley
2、停止容器
docker stop goofy_easley
root@kobe:/opt/software/docker/spring-boot-docker/target# docker stop goofy_easley
goofy_easley
goofy_easley:为docker ps返回结果中的 NAMES
3、启动容器
docker start goofy_easley
root@kobe:/opt/software/docker/spring-boot-docker/target# docker start goofy_easley
goofy_easley
4、进入容器
进入容器有多种方法,以下示例最简单的方法,使用exec
docker exec -it 5ecf2637f10b /bin/sh
5ecf2637f10b :为docker ps返回结果中的 CONTAINER ID
5、退出容器
exit
root@kobe:/opt/software/docker/spring-boot-docker/target# docker exec -it 5ecf2637f10b /bin/sh
/ # ls
app.jar bin dev etc home lib lib64 linuxrc media mnt proc root run sbin sys tmp usr var
/ # env
HOSTNAME=5ecf2637f10b
SHLVL=1
HOME=/root
JAVA_VERSION=8
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=C.UTF-8
JAVA_BUILD=03
JAVA_UPDATE=77
PWD=/
JAVA_HOME=/usr/lib/jvm/default-jvm
/ #
/ # exit
root@kobe:/opt/software/docker/spring-boot-docker/target#