【Docker之进入容器操作】
[root@bogon ~]# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@bogon ~]# docker search centos
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@bogon ~]# systemctl start docker
[root@bogon ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/haproxy latest 0e70860c9b84 5 days ago 69.5 MB
docker.io/nginx latest 71c43202b8ac 6 days ago 109 MB
docker.io/mongo-express latest d3f93978bf53 11 days ago 97.2 MB
docker.io/mongo latest a41c82c0998a 11 days ago 380 MB
docker.io/kibana latest 1f30aec345e3 11 days ago 390 MB
docker.io/elasticsearch latest 097d037f8ff8 11 days ago 486 MB
docker.io/tomcat latest 690cb3b9c7d1 13 days ago 463 MB
docker.io/resin/rpi-raspbian latest 365783567b86 2 weeks ago 126 MB
docker.io/jetty latest 07b6d9a3f5d2 3 weeks ago 453 MB
docker.io/mysql latest 29e0ae3b69b9 3 weeks ago 484 MB
docker.io/zookeeper latest 29d319df9c13 3 weeks ago 149 MB
docker.io/centos latest 5182e96772bf 4 weeks ago 200 MB
docker.io/redis latest 4e8db158f18d 4 weeks ago 83.4 MB
docker.io/wurstmeister/kafka latest e4c6cedf70f9 4 weeks ago 312 MB
docker.io/storm latest 0adcd94d5ef3 7 weeks ago 314 MB
docker.io/million12/varnish latest d4b511cda342 4 months ago 309 MB
docker.io/zeusxiao/static-dev-server latest ab422d1a9e84 13 months ago 682 MB
docker.io/tomcat 8.5.16 b226d7ee3462 13 months ago 292 MB
docker.io/longhronshens/mycat-docker latest f9a4ece7c742 13 months ago 793 MB
docker.io/airdock/oracle-jdk latest c64f85af84fa 16 months ago 533 MB
docker.io/java latest d23bdf5b1b1b 19 months ago 643 MB
docker.io/sebp/lighttpd latest 6b681cc70957 22 months ago 8.53 MB
[root@bogon ~]# docker run -i -t b226d7ee3462 /bin/bash
root@2c21c2cc21aa:/usr/local/tomcat# ls
LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf include lib logs native-jni-lib temp webapps work
root@2c21c2cc21aa:/usr/local/tomcat# cd /
root@2c21c2cc21aa:/# ls
bin boot dev docker-java-home etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@2c21c2cc21aa:/# exit
[root@bogon ~]# docker run -i -t -d -p 80:8080 b226d7ee3462
853bbb2f3367de5ddd84693e7dc6f6041331e0343e3016782000a7c4acdd790d
[root@bogon ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
853bbb2f3367 b226d7ee3462 "catalina.sh run" 47 seconds ago Up 45 seconds 0.0.0.0:80->8080/tcp suspicious_joliot
[root@bogon ~]# docker cp 853bbb2f3367:/usr/local/tomcat/conf/tomcat-users.xml /tmp/
[root@bogon ~]# vi /tmp/tomcat-users.xml
[root@bogon ~]# docker cp /tmp/tomcat-users.xml 853bbb2f3367:/usr/local/tomcat/conf/
[root@bogon ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
853bbb2f3367 b226d7ee3462 "catalina.sh run" 3 minutes ago Up 3 minutes 0.0.0.0:80->8080/tcp suspicious_joliot
[root@bogon ~]# docker kill 853bbb2f3367
853bbb2f3367
[root@bogon ~]# docker run -i -t -d -p 80:8080 b226d7ee3462
5b13ca01216d770793560e2b5848b9587aa783379af7e10fcb39ceccfeaa353f
[root@bogon ~]# docker run -i -t b226d7ee3462
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /docker-java-home/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
05-Sep-2018 01:16:06.772 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.16
05-Sep-2018 01:16:06.774 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 21 2017 17:01:09 UTC
05-Sep-2018 01:16:06.774 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.16.0
Docker文件Copy
从主机复制到容器sudo docker cp host_path containerID:container_path
从容器复制到主机sudo docker cp containerID:container_path host_path