docker Tomcat镜像

docker中的管理命令

首先需要去下载镜像。

[root@CFCA ~]# docker pull tomcat    下载镜像
[root@CFCA ~]# docker images       #该命令可以查看本地的docker镜像
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
winter/mynginx      v1                  3f7f2576105a        19 hours ago        200 MB
docker.io/tomcat    latest              41a54fe1f79d        4 days ago          463 MB
docker.io/nginx     latest              06144b287844        12 days ago         109 MB
docker.io/centos    latest              5182e96772bf        5 weeks ago         200 MB

对本地的镜像做一个本地以后再使用的时候就可以直接导入了。

[root@CFCA ~]#docker save 41a54fe1f79d > /opt/tomcat.tar.gz    IMAGE ID
下次使用的时候直接导入就可以了。

[root@CFCA ~]# docker load < /opt/tomcat.tar.gz  

 [root@CFCA ~]#docker run --name mytomcat -d -p 16000:8080 tomcat  创建一个容器

参数-d 在后台运行,-p 指定端口

 [root@CFCA ~]# docker ps   查看运行的容器
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
c661aa829f40        tomcat              "catalina.sh run"        About an hour ago   Up About an hour    0.0.0.0:16000->8080/tcp   mytomcat
adc14b5769df        nginx               "nginx -g 'daemon ..."   22 hours ago        Up About an hour    0.0.0.0:81->80/tcp        hardcore_payne

 [root@CFCA ~]# docker ps -a    查看所有的容器(正在运行的和停止的)
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                     NAMES
c661aa829f40        tomcat              "catalina.sh run"        About an hour ago   Up About an hour            0.0.0.0:16000->8080/tcp   mytomcat
5e9c5e1bd5d9        winter/mynginx:v1   "/bin/bash"              20 hours ago        Exited (1) 19 hours ago                               nginxv1
d761256a46c1        centos              "/bin/bash"              21 hours ago        Exited (137) 16 hours ago                             mynginx
6d7abc216d0c        centos              "/bin/bash"              21 hours ago        Exited (0) 19 hours ago                               test1
2363708c4ac2        centos              "/bin/bash"              21 hours ago        Exited (0) 21 hours ago                               nfs
82b6668c8585        centos              "/bin/bash"              22 hours ago        Exited (0) 22 hours ago                               dazzling_davinci
b811885dc8a0        centos              "/bin/bash"              22 hours ago        Exited (137) 16 hours ago                             jovial_nobel
6965e5bd7160        centos              "/bin/bash"              22 hours ago        Exited (137) 16 hours ago                             volume-test1
adc14b5769df        nginx               "nginx -g 'daemon ..."   22 hours ago        Up About an hour            0.0.0.0:81->80/tcp        hardcore_payne
58251af60714        nginx               "nginx -g 'daemon ..."   23 hours ago        Exited (0) 16 hours ago                               wizardly_yalow
fd407279539f        centos              "/bin/bash"              24 hours ago        Exited (137) 16 hours ago                             mydocker
4ece66925450        centos              "/bin/echo welcome"      25 hours ago        Exited (0) 25 hours ago                               stoic_jepsen
进入到容器中的方法:

找到docker运行的进程

[root@localhost ~]# docker inspect --format "{{.State.Pid}}" c661aa829f40
6059
[root@localhost ~]# nsenter -t 6059 -u -i -n -p
[root@c661aa829f40 ~]#
此时进入到了容器中。
在网页测试Tomcat的启动情况:

此时可以访问了。

 

 

 

 

posted @ 2018-09-17 15:42  winterforever  阅读(667)  评论(0编辑  收藏  举报