Docker Tomcat镜像制作(2)

[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:8
Trying to pull repository docker.io/library/tomcat ...
8: 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:8
[root@localhost sysctl.d]#

验证
docker images

[root@localhost sysctl.d]# docker images
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
docker.io/tomcat    8                  dd6ff929584a        2 weeks ago        463 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 8080:8080 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.查看运行中的容器

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0f1ddbffc5216efd535d2857825b3953.html