[root@localhost sysctl.d]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" 22 seconds ago Up 20 seconds 0.0.0.0:8080->8080/tcp youthful_carson
[root@localhost sysctl.d]# cd
6.进入已经运行的容器
docker exec -it containerID /bin/bash 这个命令exit退出,ok容器还在运行
docker attach id 刚方法进入之后,exit退出就会导致容器stop
[root@localhost sysctl.d]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" 22 seconds ago Up 20 seconds 0.0.0.0:8080->8080/tcp youthful_carson
27c726b541d5 mytomcat:1.0 "/root/run.sh" 14 hours ago Up 14 hours 0.0.0.0:58080->8080/tcp mytomcat_1
6afe7d52b011 9f3 "/bin/bash" 15 hours ago Exited (0) 15 hours ago jovial_mayer
8e9e23f4cd3b 9f3 "/bin/bash" 16 hours ago Exited (127) 15 hours ago admiring_rosalind
[root@localhost sysctl.d]# cd
[root@localhost ~]#
[root@localhost ~]# docker exec -it 6a3c /bin/bash
root@6a3c7c96df93:/usr/local/tomcat#
添加新文件
root@6a3c7c96df93:/usr/local/tomcat/webapps# cd ROOT/
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT# ls
RELEASE-NOTES.txt asf-logo-wide.svg bg-middle.png bg-nav.png favicon.ico tomcat-power.gif tomcat.gif tomcat.svg
WEB-INF bg-button.png bg-nav-item.png bg-upper.png index.jsp tomcat.css tomcat.png
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT# mkdir test
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT# cd test
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# vi showpage.jsp
bash: vi: command not found
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# tounch showpage.jsp
bash: tounch: command not found
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# touch showpage.jsp
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# vi showpage.jsp
bash: vi: command not found
无法使用vi vim
apt-get update,这个命令的作用是:同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
等更新完毕以后再敲命令:apt-get install vi命令即可
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# apt-get update
Ign:1 stretch InRelease
Get:2 stretch-updates InRelease [91.0 kB]
Get:3 stretch Release [118 kB]
Get:4 stretch-updates/main amd64 Packages [11.1 kB]
Get:5 stretch Release.gpg [2434 B]
Get:6 stretch/main amd64 Packages [7084 kB]
Err:7 stretch/updates InRelease
Cannot initiate the connection to prod.debian.map.fastly.net:80 (2a04:4e42:a::204). - connect (101: Network is unreachable) Cannot initiate the connection to security.debian.org:80 (2401:2500:103:11a::74). - connect (101: Network is unreachable) [IP: 2401:2500:103:11a::74 80]
Fetched 7306 kB in 43s (168 kB/s)
Reading package lists... Done
W: Failed to fetch Cannot initiate the connection to prod.debian.map.fastly.net:80 (2a04:4e42:a::204). - connect (101: Network is unreachable) Cannot initiate the connection to security.debian.org:80 (2401:2500:103:11a::74). - connect (101: Network is unreachable) [IP: 2401:2500:103:11a::74 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test#
仍然不可用并提示E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?