先把war 放到 特定位置 /usr/local/xxm/
xxm-admin-1.0.0-SNAPSHOT.war
在一个空白目录(/usr/local/xxm/)中,建立一个文本文件,并命名为 Dockerfile
FROM tomcat
Run rm -fr /usr/local/tomcat/webapps/ROOT/*
COPY xxm-admin-1.0.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT/
WORKDIR /usr/local/tomcat/webapps/ROOT/
RUN unzip xxm-admin-1.0.0-SNAPSHOT.war
RUN rm -fr xxm-admin-1.0.0-SNAPSHOT.war
WORKDIR /usr/local/tomcat/
构建镜像
$ docker build -t admin:v1 .
admin:v1(项目名称和标签) .(上下文路径)
image
构建成功
启动 admin
docker run -p 8080:8080 admin:v1
docker ps
docker logs -f [contain ID]
确认启动成功
启动成功
使用 docker-compose 启动admin
version: '3'
services:
admin:
restart: always
image: tomcat
container_name: admin
ports:
- 8080:8080
volumes:
- /usr/local/docker/xxm/ROOT:/usr/local/tomcat/webapps/ROOT
~
网友评论