給自己

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

結(jié)果展示

上下文環(huán)境


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 . 上下文環(huán)境
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"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 . 上下文環(huán)境
root@22a13604a4d6:/usr/local/tomcat/webapps/ROOT# 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末拼卵,一起剝皮案震驚了整個濱河市难捌,隨后出現(xiàn)的幾起案子亿鲜,更是在濱河造成了極大的恐慌,老刑警劉巖饲化,帶你破解...
    沈念sama閱讀 211,884評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異嗅绸,居然都是意外死亡渐夸,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,347評論 3 385
  • 文/潘曉璐 我一進(jìn)店門源祈,熙熙樓的掌柜王于貴愁眉苦臉地迎上來煎源,“玉大人,你說我怎么就攤上這事香缺∈窒” “怎么了?”我有些...
    開封第一講書人閱讀 157,435評論 0 348
  • 文/不壞的土叔 我叫張陵图张,是天一觀的道長原献。 經(jīng)常有香客問我馏慨,道長,這世上最難降的妖魔是什么姑隅? 我笑而不...
    開封第一講書人閱讀 56,509評論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮倔撞,結(jié)果婚禮上讲仰,老公的妹妹穿的比我還像新娘。我一直安慰自己痪蝇,他們只是感情好鄙陡,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,611評論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著躏啰,像睡著了一般趁矾。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上给僵,一...
    開封第一講書人閱讀 49,837評論 1 290
  • 那天毫捣,我揣著相機(jī)與錄音,去河邊找鬼帝际。 笑死蔓同,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的蹲诀。 我是一名探鬼主播斑粱,決...
    沈念sama閱讀 38,987評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼脯爪!你這毒婦竟也來了则北?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,730評論 0 267
  • 序言:老撾萬榮一對情侶失蹤痕慢,失蹤者是張志新(化名)和其女友劉穎尚揣,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體守屉,經(jīng)...
    沈念sama閱讀 44,194評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡惑艇,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,525評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了拇泛。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片滨巴。...
    茶點(diǎn)故事閱讀 38,664評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖俺叭,靈堂內(nèi)的尸體忽然破棺而出恭取,到底是詐尸還是另有隱情,我是刑警寧澤熄守,帶...
    沈念sama閱讀 34,334評論 4 330
  • 正文 年R本政府宣布蜈垮,位于F島的核電站耗跛,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏攒发。R本人自食惡果不足惜调塌,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,944評論 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望惠猿。 院中可真熱鬧羔砾,春花似錦、人聲如沸偶妖。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,764評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽趾访。三九已至态秧,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間扼鞋,已是汗流浹背申鱼。 一陣腳步聲響...
    開封第一講書人閱讀 31,997評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留藏鹊,地道東北人润讥。 一個月前我還...
    沈念sama閱讀 46,389評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像盘寡,于是被迫代替她去往敵國和親楚殿。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,554評論 2 349

推薦閱讀更多精彩內(nèi)容