Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a java running environment in Docker

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Docker how to build a java operating environment, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

First of all, you should pack your own jar package and then write the dockerfile file:

FROM openjdk:8-jdk-alpineENV LANG C.UTF-8RUN apk-- update add ttf-dejavu & &\ rm-rf / var/cache/apk/*MAINTAINER "haolin#189.cn" LABEL description= "jarrunner" WORKDIR appADD admin.jar / app/app.jarEXPOSE 8081CMD java-jar / app/app.jar

The main thing is to add font library.

When finished, execute docker build-t username / image name: 1.01. You can complete the image encapsulation.

You can see the finished image package by viewing the image through docker image ls.

Then build the docker-compose file, map the app directory under the running directory to docker by setting the mapping directory, and rename the jar package to app.jar.

Volumes:

-. / app:/app

I still suggest that docker and mysql be packaged together:

Version: '3'services: app: container_name: XXXX_app image: haol666/XXXX:1.01 network_mode: "service:mysql" volumes: -. / app:/app depends_on:-mysqlmysql: container_name: xxxx_mysql image: mysql:5.7 command:-- character-set-server=utf8mb4-- collation-server=utf8mb4_general_ci-- explicit_defaults_for_timestamp=true-- lower_case_table_ Names=1-max_allowed_packet=128M-sql-mode= "STRICT_TRANS_TABLES NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO "environment: TZ: Asia/Shanghai MYSQL_DATABASE: XXXX MYSQL_ROOT_PASSWORD: XXXX MYSQL_USER: 'XXXX' MYSQL_PASS:' XXXX' MYSQL_HOST:'% 'volumes: -. / data:/var/lib/mysql ports: -" 8080 TZ 443 "expose: -" 8080 "

After the configuration is complete, pass:

Docker-compose up creates a mirror

Start mirroring through docker-compose start

Stop mirroring through docker-compose stop

Docker-compose down deletes the mirror.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report