docker tomcat镜像制作
推荐使用dockerfile(本文直接拉取tomcat需要进入容器自行安装vim):docker利用Dockerfile来制作镜像
1.查找Docker Hub上的tomcat镜像
[root@localhost sysctl.d]# docker search tomcat
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/tomcat Apache Tomcat is an open source implementa... [OK]
docker.io docker.io/tomee Apache TomEE is an all-Apache Java EE cert... [OK]
docker.io docker.io/dordoka/tomcat Ubuntu 14.04, Oracle JDK and Tomcat ba... [OK]
docker.io docker.io/davidcaste/alpine-tomcat Apache Tomcat / using Oracle Java / wi... [OK]
docker.io docker.io/bitnami/tomcat Bitnami Tomcat Docker Image [OK]
docker.io docker.io/cloudesire/tomcat Tomcat server, // [OK]
docker.io docker.io/meirwa/spring-boot-tomcat-mysql-app a sample spring-boot app using tomcat and ... [OK]
docker.io docker.io/aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL [OK]
docker.io docker.io/tutum/tomcat Base docker image to run a Tomcat applicat...
docker.io docker.io/jeanblanchard/tomcat Minimal Docker image with Apache Tomcat
docker.io docker.io/arm32v7/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/maluuba/tomcat7-java8 Tomcat7 with java8.
docker.io docker.io/rightctrl/tomcat CentOS , Oracle Java, tomcat application s... [OK]
docker.io docker.io/amd64/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/arm64v8/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/fabric8/tomcat- Fabric8 Tomcat Image [OK]
docker.io docker.io/99taxis/tomcat7 Tomcat7 [OK]
docker.io docker.io/camptocamp/tomcat-logback Docker image for tomcat with logback integ... [OK]
docker.io docker.io/1and1internet/debian--java--tomcat-8.5 Our tomcat 8.5 image [OK]
docker.io docker.io/cfje/tomcat-resource Tomcat Concourse Resource
docker.io docker.io/jelastic/tomcat An image of the Tomcat Java application se...
docker.io docker.io/oobsri/tomcat8 Testing CI Jobs with different names.
docker.io docker.io/picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAG... [OK]
docker.io docker.io/s390x/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/swisstopo/service-print-tomcat backend tomcat for service-print "the true... 0
2.查看本地已有镜像
docker images
[root@localhost sysctl.d]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
3.拉取镜像
docker pull tomcat:8 ##version 如果很慢请参照:docker pull centos慢问题的解决方案
[root@localhost sysctl.d]# docker pull tomcat:
Trying to pull repository docker.io/library/tomcat ...
: Pulling from docker.io/library/tomcat
22dbe790f715: Pull complete
0250231711a0: Pull complete
6fba9447437b: Pull complete
4afad9c4aba6: Pull complete
12fce9923c9d: Pull complete
0dd81083d77e: Pull complete
4c2afc6ff72d: Pull complete
a62332a260f5: Pull complete
96dfb5ad080f: Pull complete
782f63228ce1: Pull complete
d610fffe30ad: Pull complete
Digest: sha256:aacce4e5ca37a3b8241c544deffd65f4cafbfb1a2fb2066f97621253c34f7dc4
Status: Downloaded newer image for docker.io/tomcat:
[root@localhost sysctl.d]#
验证
docker images
[root@localhost sysctl.d]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/tomcat dd6ff929584a weeks ago MB
[root@localhost sysctl.d]#
4.启动tomcat
docker run -d -p 8080:8080 tomcat ####前者是外部访问端口,后者是容器内映射端口
如下命令可后台启动tomcat
-d: 后台运行容器,并返回容器ID;
-i: 以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
[root@localhost sysctl.d]# docker run -d -p : tomcat
Unable to find image 'tomcat:latest' locally
Trying to pull repository docker.io/library/tomcat ...
latest: Pulling from docker.io/library/tomcat
Digest: sha256:aacce4e5ca37a3b8241c544deffd65f4cafbfb1a2fb2066f97621253c34f7dc4
Status: Downloaded newer image for docker.io/tomcat:latest
6a3c7c96df932566cc24cf7811ba774eb4c3f59f498ffc79d9f576ba2c589d04
5.查看运行中的容器
[root@localhost sysctl.d]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" seconds ago Up seconds 0.0.0.0:->/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" seconds ago Up seconds 0.0.0.0:->/tcp youthful_carson
27c726b541d5 mytomcat:1.0 "/root/run.sh" hours ago Up hours 0.0.0.0:->/tcp mytomcat_1
6afe7d52b011 9f3 "/bin/bash" hours ago Exited () hours ago jovial_mayer
8e9e23f4cd3b 9f3 "/bin/bash" hours ago Exited () 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: http://deb.debian.org/debian stretch InRelease
Get: http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get: http://deb.debian.org/debian stretch Release [118 kB]
Get: http://deb.debian.org/debian stretch-updates/main amd64 Packages [11.1 kB]
Get: http://deb.debian.org/debian stretch Release.gpg [2434 B]
Get: http://deb.debian.org/debian stretch/main amd64 Packages [7084 kB]
Err: http://security.debian.org/debian-security stretch/updates InRelease
Cannot initiate the connection to prod.debian.map.fastly.net: (2a04:4e42:a::). - connect (: Network is unreachable) Cannot initiate the connection to security.debian.org: (:::11a::). - connect (: Network is unreachable) [IP: :::11a:: ]
Fetched kB in 43s ( kB/s)
Reading package lists... Done
W: Failed to fetch http://security.debian.org/debian-security/dists/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]
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?
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# apt-get install vim --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libgpm2 vim-common vim-runtime xxd
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 vim vim-common vim-runtime xxd
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, 31.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get: http://cdn-fastly.deb.debian.org/debian stretch/main amd64 xxd amd64 2:8.0.0197-4+deb9u1 [132 kB]
Get: http://cdn-fastly.deb.debian.org/debian stretch/main amd64 vim-common all 2:8.0.0197-4+deb9u1 [159 kB]
Get: http://cdn-fastly.deb.debian.org/debian stretch/main amd64 libgpm2 amd64 1.20.4-6.2+b1 [34.2 kB]
Get: http://cdn-fastly.deb.debian.org/debian stretch/main amd64 vim-runtime all 2:8.0.0197-4+deb9u1 [5407 kB]
Get: http://cdn-fastly.deb.debian.org/debian stretch/main amd64 vim amd64 2:8.0.0197-4+deb9u1 [1034 kB]
Fetched kB in 8min 44s (12.9 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package xxd.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../xxd_2%3a8.0.0197-+deb9u1_amd64.deb ...
Unpacking xxd (:8.0.-+deb9u1) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a8.0.0197-+deb9u1_all.deb ...
Unpacking vim-common (:8.0.-+deb9u1) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../libgpm2_1.20.4-6.2+b1_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.-6.2+b1) ...
Selecting previously unselected package vim-runtime.
;?eparing to unpack .../vim-runtime_2%3a8.0.0197-+deb9u1_all.deb ...
ding 'diversion of /usr/share/vim/vim80/doc/help.txt to /usr/share/vim/vim80/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim80/doc/tags to /usr/share/vim/vim80/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (:8.0.-+deb9u1) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.0.0197-+deb9u1_amd64.deb ...
Unpacking vim (:8.0.-+deb9u1) ...
Setting up xxd (:8.0.-+deb9u1) ...
Setting up libgpm2:amd64 (1.20.-6.2+b1) ...
Processing triggers for libc-bin (2.24-+deb9u4) ...
Setting up vim-common (:8.0.-+deb9u1) ...
Setting up vim-runtime (:8.0.-+deb9u1) ...
Processing triggers for hicolor-icon-theme (0.15-) ...
Setting up vim (:8.0.-+deb9u1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
7.添加hello wold页面
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# pwd
/usr/local/tomcat/webapps/ROOT/test root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# vi showpage.jsp
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# cat showpage.jsp
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test#
8.基于此制作新镜像
退出6a3c 容器,并停止容器
root@6a3c7c96df93:/usr/local/tomcat/webapps/ROOT/test# exit
exit
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" hours ago Up hours 0.0.0.0:->/tcp youthful_carson
[root@localhost ~]# docker stop 6a3c
6a3c
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" hours ago Exited () seconds ago youthful_carson
[root@localhost ~]#
使用以下命令,根据某个“容器 ID”来创建一个新的“镜像”:
docker commit 6a3c my_tomcat:1.0
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 9f38484d220f 11 days ago 202 MB
docker.io/tomcat 8 dd6ff929584a 2 weeks ago 463 MB
[root@localhost ~]# [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" hours ago Exited () minutes ago youthful_carson
[root@localhost ~]# docker commit 6a3c my_tomcat:1.0
sha256:20e7c603432c2d9b39598809a028cf9f4e30eb43bf3b5db287fb278d7cb43e11
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_tomcat 1.0 20e7c603432c 14 seconds ago 510 MB
docker.io/centos latest 9f38484d220f days ago MB
docker.io/tomcat dd6ff929584a weeks ago MB
[root@localhost ~]#
9.验证新镜像
docker run -d -p 8080:8080 my_tomcat
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3c7c96df93 tomcat "catalina.sh run" hours ago Exited () minutes ago youthful_carson [root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_tomcat 1.0 20e7c603432c minutes ago MB
docker.io/centos latest 9f38484d220f days ago MB
docker.io/tomcat dd6ff929584a weeks ago MB
[root@localhost ~]# docker run -d -p : --name my_tomcat_00 my_tomcat
Unable to find image 'cmiot_tomcat:latest' locally
Trying to pull repository docker.io/library/cmiot_tomcat ...
/usr/bin/docker-current: repository docker.io/cmiot_tomcat not found: does not exist or no pull access.
See '/usr/bin/docker-current run --help'.
[root@localhost ~]# docker run -d -p 8080:8080 --name my_tomcat_00 my_tomcat:1.0
0a299b64105fac63371978168a67f9015b361f9816678c0e4bb2ee174aa6ef55
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a299b64105f my_tomcat:1.0 "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:->/tcp my_tomcat_00
6a3c7c96df93 tomcat "catalina.sh run" hours ago Exited () minutes ago youthful_carson
[root@localhost ~]#
docker tomcat镜像制作的更多相关文章
- 测试环境docker化(一)—基于ndp部署模式的docker基础镜像制作
本文来自网易云社区 作者:孙婷婷 背景 我所在测试项目组目前的测试环境只有一套,在项目版本迭代过程中,开发或产品偶尔会在测试环境进行数据校验,QA人数在不断增加,各个人员在负责不同模块工作时也会产生脏 ...
- 中标麒麟龙芯平台--docker基础镜像制作
Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源.Docker 的出现为开发人员和运维人员带来了极大的便利.Docker在X86下常见的发行版Linux如Ub ...
- centos7创建docker tomcat镜像
1 准备宿主系统 准备一个 CentOS 7操作系统,具体要求如下: 必须是 64 位操作系统 建议内核在 3.8 以上 通过以下命令查看您的 CentOS 内核: 1 # uname -r 2 安装 ...
- docker tomcat镜像部署springbootwar包
springboot打war包 1.在pom文件中增加插件 <build> <finalName>xx</finalName> <plugins> &l ...
- k8s+docker+proget 镜像制作
安装proget 1 首先在k8s上运行proget的数据库配置有个注意点:要根据proget官网要求的sql server排序方式建数据库,不然数据保存的时候会报错 2 proget运行起来后,默认 ...
- docker之镜像制作
#:下载镜像并初始化系统 root@ubuntu:~# docker pull centos #:创建目录 root@ubuntu:/opt# mkdir dockerfile/{web/{nginx ...
- Docker的镜像制作与整套项目一键打包部署
Dockerfile常用指令介绍 指令 描述 FROM 构建的新镜像是基于哪个镜像.例如:FROM centos:6 MAINTAINER 镜像维护者姓名或邮箱地址.例如:MAINTAINER Mr. ...
- docker Tomcat镜像
docker中的管理命令 首先需要去下载镜像. [root@CFCA ~]# docker pull tomcat 下载镜像[root@CFCA ~]# docker images ...
- Dockerfile Tomcat镜像制作
FROM centos MAINTAINER taohaijun "thjtao@126.com" WORKDIR /home #上传安装包 COPY jdk-8u131-linu ...
随机推荐
- C++进阶--自定义new handler
//############################################################################ // 自定义new handler /* ...
- uoj#209. 【UER #6】票数统计
http://uoj.ac/problem/209 当x!=y时,这个限制条件是确定的,可以枚举总通过数,用组合数计算,当x==y时,这个限制条件表示前x个全部通过或后x个全部通过,只有最大的x有用, ...
- vultr上 windows使用pptp拨号来实现冗余双网关的解决方案
rasdial是拨号程序,pptpvpn是网卡拨号名称,后面跟的是帐号和密码.pptpvpn见下图:就是提前创建好一个PPTP的拨号连接 上面是启动时候的计划任务,那么万一拨号中断,要继续重拨还需要做 ...
- RabbitMQ入门教程(十):队列声明queueDeclare(转载)
原文转载至:https://blog.csdn.net/vbirdbest/article/details/78670550 简介本节主要讨论队列声明的各个参数 queueDeclare(String ...
- android adb push 命令
1.获得root权限:adb root 2.设置/system为可读写:adb remount 3.将PC机上文件复制到手机:adb push 文件名 /system/lib
- Mysql 之分库分表方案
Mysql分库分表方案 为什么要分表 当一张表的数据达到几千万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了.分表的目的就在于此,减小数据库的负担,缩短查询时间. mysq ...
- C#存储过程 传入参数 传出参数 结果集
作者:卞功鑫 转载请保留:http://www.cnblogs.com/BinBinGo/p/6400928.html //1 连接字符串 string connectionString = &quo ...
- restful 涵义
REST,即Representational State Transfer的缩写: "表现层状态转化" REST的名称"表现层状态转化"中,省略了主语.&quo ...
- 第11章 拾遗4:IPv6(3)_配置IPv6路由
5. 配置IPv6路由 5.1 配置IPv6静态路由 (1)在路由器上配置静态路由(以R1路由器为例) //静态路由 R1#config t R1(config)#ipv6 unicast-routi ...
- centos7安装zookeeper3.4.12集群
zookeeper的三要素: 1.一致,能够保证数据的一致性 2.有头,始终有一个leader,node/2+1个节点有效,就能正常工作 3.数据树,树状结构且每个树必须有数据 1. 环境准备 操作系 ...