Last login: Sat Feb 9 02:33:10 2019 from 192.168.17.1
[root@zft ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ae2aff6daf2d ipple1986/hexo "hexo server" 35 hours ago Up 35 hours 0.0.0.0:4000->4000/tcp some-hexo
cb5b22e06aa5 mysql:5.7.22 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp mysql
29ff54b3124a wordpress "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:80->80/tcp wordpress
c27ece8ced80 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp brave_snyder
[root@zft ~]# cd /usr/local/
[root@zft local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 2月 5 10:30 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@zft local]# mkdir docker
[root@zft local]# cd docker/
[root@zft docker]# mkdir tomcat
[root@zft docker]# cd tomcat/
[root@zft tomcat]# vi Dockerfile
FROM tomcat
RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
~
~
"Dockerfile" [New] 2L, 80C written
[root@zft tomcat]# cat Dockerfile
FROM tomcat
RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
[root@zft tomcat]# docker build -t mytomcat .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM tomcat
latest: Pulling from library/tomcat
741437d97401: Pull complete
34d8874714d7: Pull complete
0a108aa26679: Pull complete
eea0f08c7492: Pull complete
ca74b3d90c15: Pull complete
f11a643c4a85: Pull complete
05eafed73b65: Pull complete
f24105f282aa: Pull complete
e27e73cbbd3f: Pull complete
801f808615c2: Pull complete
294f3735a5f6: Pull complete
Digest: sha256:2af4741120ac4b2e1993412e34b73565d1b859d8a44b1b5f0e1963d97cc921a1
Status: Downloaded newer image for tomcat:latest
---> 168588387c68
Step 2/2 : RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
---> Running in 9df888b059e8
Removing intermediate container 9df888b059e8
---> 8b604d034978
Successfully built 8b604d034978
Successfully tagged mytomcat:latest
[root@zft tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 8b604d034978 16 seconds ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft tomcat]#
[root@zft tomcat]# docker run -it mytomcat bash
root@1878c9f4985b:/usr/local/tomcat# ls -a
. CONTRIBUTING.md README.md bin lib temp
.. LICENSE RELEASE-NOTES conf logs webapps
BUILDING.txt NOTICE RUNNING.txt include native-jni-lib work
root@1878c9f4985b:/usr/local/tomcat# ls -al
total 124
drwxr-sr-x. 1 root staff 21 Feb 9 02:08 .
drwxrwsr-x. 1 root staff 20 Feb 6 16:55 ..
-rw-r--r--. 1 root root 19539 Feb 5 11:45 BUILDING.txt
-rw-r--r--. 1 root root 6090 Feb 5 11:45 CONTRIBUTING.md
-rw-r--r--. 1 root root 57092 Feb 5 11:45 LICENSE
-rw-r--r--. 1 root root 1726 Feb 5 11:45 NOTICE
-rw-r--r--. 1 root root 3255 Feb 5 11:45 README.md
-rw-r--r--. 1 root root 7142 Feb 5 11:45 RELEASE-NOTES
-rw-r--r--. 1 root root 16262 Feb 5 11:45 RUNNING.txt
drwxr-xr-x. 2 root root 4096 Feb 9 02:08 bin
drwxr-sr-x. 2 root root 238 Feb 5 11:45 conf
drwxr-sr-x. 2 root staff 78 Feb 9 02:08 include
drwxr-xr-x. 2 root root 4096 Feb 9 02:08 lib
drwxrwxrwx. 2 root root 6 Feb 5 11:42 logs
drwxr-sr-x. 3 root staff 151 Feb 9 02:08 native-jni-lib
drwxr-xr-x. 2 root root 30 Feb 9 02:08 temp
drwxr-xr-x. 1 root root 18 Feb 5 11:44 webapps
drwxrwxrwx. 2 root root 6 Feb 5 11:42 work
root@1878c9f4985b:/usr/local/tomcat# cd webapps/
root@1878c9f4985b:/usr/local/tomcat/webapps# ll
bash: ll: command not found
root@1878c9f4985b:/usr/local/tomcat/webapps# ls -al
total 4
drwxr-xr-x. 1 root root 18 Feb 5 11:44 .
drwxr-sr-x. 1 root staff 21 Feb 9 02:08 ..
drwxr-xr-x. 1 root root 24 Feb 12 09:46 ROOT
drwxr-xr-x. 14 root root 4096 Feb 9 02:08 docs
drwxr-xr-x. 6 root root 83 Feb 9 02:08 examples
drwxr-xr-x. 5 root root 87 Feb 9 02:08 host-manager
drwxr-xr-x. 5 root root 103 Feb 9 02:08 manager
root@1878c9f4985b:/usr/local/tomcat/webapps# cd ROOT/
root@1878c9f4985b:/usr/local/tomcat/webapps/ROOT# ls -a
. bg-button.png favicon.ico tomcat.gif
.. bg-middle.png index.html tomcat.png
RELEASE-NOTES.txt bg-nav-item.png index.jsp tomcat.svg
WEB-INF bg-nav.png tomcat-power.gif
asf-logo-wide.svg bg-upper.png tomcat.css
root@1878c9f4985b:/usr/local/tomcat/webapps/ROOT# cat index.html
Hello Docker
root@1878c9f4985b:/usr/local/tomcat/webapps/ROOT# exit
exit
[root@zft tomcat]# vi Dockerfile
FROM tomcat
WORKDIR /usr/local/tomcat/webapps/ROOT/
RUN rm -rf *
RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
~
~
"Dockerfile" 4L, 133C written
[root@zft tomcat]# docker build -t mytomcat .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM tomcat
---> 168588387c68
Step 2/4 : WORKDIR /usr/local/tomcat/webapps/ROOT/
---> Running in b7c55dd156ab
Removing intermediate container b7c55dd156ab
---> 48fd897834d6
Step 3/4 : RUN rm -rf *
---> Running in 77dcbdb18573
Removing intermediate container 77dcbdb18573
---> 26f9f86285b5
Step 4/4 : RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
---> Running in c7cb4aeb3c52
Removing intermediate container c7cb4aeb3c52
---> 3c0cca79ebb6
Successfully built 3c0cca79ebb6
Successfully tagged mytomcat:latest
[root@zft tomcat]# docker run -it --rm mytomcat bash
root@7f46a2e91832:/usr/local/tomcat/webapps/ROOT# ls -al
total 4
drwxr-xr-x. 1 root root 24 Feb 12 09:53 .
drwxr-xr-x. 1 root root 18 Feb 5 11:44 ..
-rw-r--r--. 1 root root 13 Feb 12 09:53 index.html
root@7f46a2e91832:/usr/local/tomcat/webapps/ROOT# exit
exit
[root@zft tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 3c0cca79ebb6 About a minute ago 463MB
<none> <none> 8b604d034978 8 minutes ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft tomcat]# docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
[root@zft tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 3c0cca79ebb6 2 minutes ago 463MB
<none> <none> 8b604d034978 9 minutes ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft tomcat]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ae2aff6daf2d ipple1986/hexo "hexo server" 35 hours ago Up 35 hours 0.0.0.0:4000->4000/tcp some-hexo
cb5b22e06aa5 mysql:5.7.22 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp mysql
29ff54b3124a wordpress "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:80->80/tcp wordpress
c27ece8ced80 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp brave_snyder
[root@zft tomcat]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1878c9f4985b 8b604d034978 "bash" 9 minutes ago Exited (0) 8 minutes ago elegant_goldberg
ae2aff6daf2d ipple1986/hexo "hexo server" 35 hours ago Up 35 hours 0.0.0.0:4000->4000/tcp some-hexo
cb5b22e06aa5 mysql:5.7.22 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp mysql
29ff54b3124a wordpress "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:80->80/tcp wordpress
c27ece8ced80 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp brave_snyder
[root@zft tomcat]# docker rm 1878c9f4985b
1878c9f4985b
[root@zft tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 3c0cca79ebb6 4 minutes ago 463MB
<none> <none> 8b604d034978 11 minutes ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft tomcat]# docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:8b604d0349781c00ef92b78d3f4f9c44dd2048bfd26ebe2b79132397161157b5
deleted: sha256:6d8df8a3c4bb1cc91465c1e0362e3ea5fdaa4a1b3b2826dd992e6f9931751c4d
Total reclaimed space: 13B
[root@zft tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 3c0cca79ebb6 5 minutes ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft tomcat]# docker run -p 8080:8080 mytomcat
12-Feb-2019 10:00:43.514 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.38
12-Feb-2019 10:00:43.517 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Feb 5 2019 11:42:42 UTC
12-Feb-2019 10:00:43.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.38.0
12-Feb-2019 10:00:43.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
12-Feb-2019 10:00:43.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-957.el7.x86_64
12-Feb-2019 10:00:43.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
12-Feb-2019 10:00:43.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
12-Feb-2019 10:00:43.519 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_181-8u181-b13-2~deb9u1-b13
12-Feb-2019 10:00:43.519 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
12-Feb-2019 10:00:43.519 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
12-Feb-2019 10:00:43.519 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
12-Feb-2019 10:00:43.529 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
12-Feb-2019 10:00:43.530 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
12-Feb-2019 10:00:43.531 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
12-Feb-2019 10:00:43.531 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.5.2].
12-Feb-2019 10:00:43.531 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
12-Feb-2019 10:00:43.531 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
12-Feb-2019 10:00:43.569 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.0j 20 Nov 2018]
12-Feb-2019 10:00:43.883 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
12-Feb-2019 10:00:43.984 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
12-Feb-2019 10:00:44.026 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
12-Feb-2019 10:00:44.045 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
12-Feb-2019 10:00:44.047 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1904 ms
12-Feb-2019 10:00:44.119 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
12-Feb-2019 10:00:44.119 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.38
12-Feb-2019 10:00:44.182 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
12-Feb-2019 10:00:45.269 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [1,086] ms
12-Feb-2019 10:00:45.269 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
12-Feb-2019 10:00:45.334 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [64] ms
12-Feb-2019 10:00:45.334 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
12-Feb-2019 10:00:46.280 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [945] ms
12-Feb-2019 10:00:46.280 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
12-Feb-2019 10:00:46.376 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [96] ms
12-Feb-2019 10:00:46.377 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
12-Feb-2019 10:00:46.482 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [105] ms
12-Feb-2019 10:00:46.504 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
12-Feb-2019 10:00:46.532 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
12-Feb-2019 10:00:46.541 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2493 ms
上下文环境
Last login: Tue Feb 12 17:29:27 2019 from 192.168.17.1
[root@zft ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ae2aff6daf2d ipple1986/hexo "hexo server" 36 hours ago Up 36 hours 0.0.0.0:4000->4000/tcp some-hexo
cb5b22e06aa5 mysql:5.7.22 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp mysql
29ff54b3124a wordpress "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:80->80/tcp wordpress
c27ece8ced80 portainer/portainer "/portainer" 7 days ago Up 7 days 0.0.0.0:9000->9000/tcp brave_snyder
[root@zft ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mytomcat latest 3c0cca79ebb6 42 minutes ago 463MB
tomcat latest 168588387c68 3 days ago 463MB
mysql 5.7.25 e47e309f72c8 6 days ago 372MB
portainer/portainer latest 89c72b64ab63 12 days ago 74.2MB
wordpress latest 6e880d17852f 2 weeks ago 420MB
mysql 5.7.22 6bb891430fb6 6 months ago 372MB
ipple1986/hexo latest 8eb73a3f4772 20 months ago 427MB
[root@zft ~]# cd /usr/local/docker/
[root@zft docker]# ls
tomcat
[root@zft docker]# ll
总用量 0
drwxr-xr-x. 2 root root 24 2月 12 17:53 tomcat
[root@zft docker]# cd tomcat/
[root@zft tomcat]# ll
总用量 4
-rw-r--r--. 1 root root 133 2月 12 17:53 Dockerfile
[root@zft tomcat]# vi test.html
测试docker build -t mytomcat . 上下文环境
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"test.html" [New] 1L, 49C written
[root@zft tomcat]# ll
总用量 8
-rw-r--r--. 1 root root 133 2月 12 17:53 Dockerfile
-rw-r--r--. 1 root root 49 2月 12 18:38 test.html
[root@zft tomcat]# docker build -t mytomcat
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
[root@zft tomcat]# docker build -t mytomcat .
Sending build context to Docker daemon 3.072kB
Step 1/4 : FROM tomcat
---> 168588387c68
Step 2/4 : WORKDIR /usr/local/tomcat/webapps/ROOT/
---> Using cache
---> 48fd897834d6
Step 3/4 : RUN rm -rf *
---> Using cache
---> 26f9f86285b5
Step 4/4 : RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
---> Using cache
---> 3c0cca79ebb6
Successfully built 3c0cca79ebb6
Successfully tagged mytomcat:latest
[root@zft tomcat]# docker run -it --rm mytomcat bash
root@70f6731ec410:/usr/local/tomcat/webapps/ROOT# ll
bash: ll: command not found
root@70f6731ec410:/usr/local/tomcat/webapps/ROOT# ls -a
. .. index.html
root@70f6731ec410:/usr/local/tomcat/webapps/ROOT# exit
exit
[root@zft tomcat]# ll
总用量 8
-rw-r--r--. 1 root root 133 2月 12 17:53 Dockerfile
-rw-r--r--. 1 root root 49 2月 12 18:38 test.html
[root@zft tomcat]#
[root@zft tomcat]# vi Dockerfile
WORKDIR /usr/local/tomcat/webapps/ROOT/
FROM tomcat
WORKDIR /usr/local/tomcat/webapps/ROOT/
RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"Dockerfile" 3L, 120C written
[root@zft tomcat]# docker build -t mytomcat .
Sending build context to Docker daemon 3.072kB
Step 1/3 : FROM tomcat
---> 168588387c68
Step 2/3 : WORKDIR /usr/local/tomcat/webapps/ROOT/
---> Using cache
---> 48fd897834d6
Step 3/3 : RUN echo "Hello Docker" > /usr/local/tomcat/webapps/ROOT/index.html
---> Running in 108da695e624
Removing intermediate container 108da695e624
---> b0060d8a60f4
Successfully built b0060d8a60f4
Successfully tagged mytomcat:latest
[root@zft tomcat]# docker run -it --rm mytomcat bash
root@732c1af84b00:/usr/local/tomcat/webapps/ROOT# ls -a
. RELEASE-NOTES.txt asf-logo-wide.svg bg-middle.png bg-nav.png favicon.ico index.jsp tomcat.css tomcat.png
.. WEB-INF bg-button.png bg-nav-item.png bg-upper.png index.html tomcat-power.gif tomcat.gif tomcat.svg
root@732c1af84b00:/usr/local/tomcat/webapps/ROOT# ls
RELEASE-NOTES.txt asf-logo-wide.svg bg-middle.png bg-nav.png favicon.ico index.jsp tomcat.css tomcat.png
WEB-INF bg-button.png bg-nav-item.png bg-upper.png index.html tomcat-power.gif tomcat.gif tomcat.svg
root@732c1af84b00:/usr/local/tomcat/webapps/ROOT# ll
bash: ll: command not found
root@732c1af84b00:/usr/local/tomcat/webapps/ROOT# ls -al
total 192
drwxr-xr-x. 1 root root 24 Feb 12 10:40 .
drwxr-xr-x. 1 root root 18 Feb 5 11:44 ..
-rw-r--r--. 1 root root 7142 Feb 5 11:45 RELEASE-NOTES.txt
drwxr-xr-x. 2 root root 21 Feb 9 02:08 WEB-INF
-rw-r--r--. 1 root root 27235 Feb 5 11:45 asf-logo-wide.svg
-rw-r--r--. 1 root root 713 Feb 5 11:44 bg-button.png
-rw-r--r--. 1 root root 1918 Feb 5 11:44 bg-middle.png
-rw-r--r--. 1 root root 1392 Feb 5 11:44 bg-nav-item.png
-rw-r--r--. 1 root root 1401 Feb 5 11:44 bg-nav.png
-rw-r--r--. 1 root root 3103 Feb 5 11:44 bg-upper.png
-rw-r--r--. 1 root root 21630 Feb 5 11:44 favicon.ico
-rw-r--r--. 1 root root 13 Feb 12 10:40 index.html
-rw-r--r--. 1 root root 12290 Feb 5 11:45 index.jsp
-rw-r--r--. 1 root root 2376 Feb 5 11:44 tomcat-power.gif
-rw-r--r--. 1 root root 5581 Feb 5 11:45 tomcat.css
-rw-r--r--. 1 root root 2066 Feb 5 11:44 tomcat.gif
-rw-r--r--. 1 root root 5103 Feb 5 11:44 tomcat.png
-rw-r--r--. 1 root root 67795 Feb 5 11:45 tomcat.svg
root@732c1af84b00:/usr/local/tomcat/webapps/ROOT# exit
exit
[root@zft tomcat]# ll
总用量 8
-rw-r--r--. 1 root root 120 2月 12 18:40 Dockerfile
-rw-r--r--. 1 root root 49 2月 12 18:38 test.html
[root@zft tomcat]# vi Dockerfile
FROM tomcat
WORKDIR /usr/local/tomcat/webapps/ROOT/
RUN rm -rf *
COPY test.html /usr/local/tomcat/webapps/ROOT/
RUN echo "hello docker" > /usr/local/tomcat/webapps/ROOT/index.html
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"Dockerfile" 5L, 180C written
[root@zft tomcat]# docker build -t mytomcat .
Sending build context to Docker daemon 3.072kB
Step 1/5 : FROM tomcat
---> 168588387c68
Step 2/5 : WORKDIR /usr/local/tomcat/webapps/ROOT/
---> Using cache
---> 48fd897834d6
Step 3/5 : RUN rm -rf *
---> Using cache
---> 26f9f86285b5
Step 4/5 : COPY test.html /usr/local/tomcat/webapps/ROOT/
---> 21a2101ffdde
Step 5/5 : RUN echo "hello docker" > /usr/local/tomcat/webapps/ROOT/index.html
---> Running in ce794f2112b5
Removing intermediate container ce794f2112b5
---> 0d76c7daa9b4
Successfully built 0d76c7daa9b4
Successfully tagged mytomcat:latest
[root@zft tomcat]# docker run -it --rm mytomcat bash
root@22a13604a4d6:/usr/local/tomcat/webapps/ROOT# ls -al
total 8
drwxr-xr-x. 1 root root 24 Feb 12 10:46 .
drwxr-xr-x. 1 root root 18 Feb 5 11:44 ..
-rw-r--r--. 1 root root 13 Feb 12 10:46 index.html
-rw-r--r--. 1 root root 49 Feb 12 10:38 test.html
root@22a13604a4d6:/usr/local/tomcat/webapps/ROOT# cat index.html
hello docker
root@22a13604a4d6:/usr/local/tomcat/webapps/ROOT# cat test.html
测试docker build -t mytomcat . 上下文环境
root@22a13604a4d6:/usr/local/tomcat/webapps/ROOT#