Deploy your own project through docker

Recently, several juniors are working on life panel projects and don’t know how to use docker to deploy projects, (saving a lot of cloud server costs)

Create image through Dockerfile

Replace all the accessed ip addresses with aliases

First put the j project jar package and Dockerfile file: in the directory, used to generate the project container image
/var/lib/docker/tmp
My Dockerfile file:
FROM jdk8 #Basic image EXPOSE
8080
VOLUME /tmp
ENV TZ=Asia/Shanghai
RUN ln- sf /usr/share/zoneinfo/{TZ} /etc/locatime && echo “{TZ}”> /etc/timezone
#Time zone setting ADD myshop.war /app.jar
RUN bash -c'touch /app.jar '
ENTRYPOINT "java","-jar","app.jar"
Run the command
docker build -t myshop.
Run results
Create successfully

Insert picture description here

Then create a container through mirroring

Direct association of containers (running mutual access)

Each container has an alias, which is equivalent to an ip address

docker run -p 8080:8080 -p 9090:9090 --name myshop myshop --link myshop:lmyshop --link myredis:lmyredis -d
myshop: container name
lmyshop: container alias

Guess you like

Origin blog.csdn.net/weixin_43158695/article/details/107118786