In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to turn a jar package into a docker container. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
How to turn a jar package into a docker container
1. Download the java image first.
Docker pull java:8
2. Create a new working directory and copy the jar package into it.
Mkdir mydockercd mydockercopy / xxx/app.jar. /
3. Create a new Dockerfile file
Vi Dockerfile
The contents of the document are as follows:
FROM java:8MAINTAINER freebytes.netWORKDIR / testCOPY app.jar / test/app.jarCMD ["java", "- jar", "app.jar", "- Dfile.encoding=utf-8"]
Code interpretation
FROM java:8-indicates that it is built based on java:8 images
MAINTAINER author-- indicates that the builder is author.
WORKDIR / test-indicates that the working directory in the specified container is / test
COPY-copy app.jar to the container working directory / test
CMD-executes the instructions of java to start jar.
4. Build an image
Docker build-t app-docker.
It means to build an image from the current directory. This command will package and send all the files in the current directory to the server of the docker engine, and then build according to Dockerfile on the server.
5. After the construction is successful, start the container
Docker run-it-p 9013 name app 8088-name app-d my-docker
According to the Dockerfile configuration just now, after the container is generated, the test directory will be generated under the container root directory, and there is an app.jar file in the test directory. The instructions for the container to execute the CMD definition are also based on the test directory.
You can enter the inside of the container for viewing
Docker exec-it app / bin/bash Thank you for your reading! This is the end of this article on "how to turn a jar package into a docker container". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Environment Vmware virtual machine OS:CentOS7 fault simulation fault repair
© 2024 shulou.com SLNews company. All rights reserved.