The saying goes that way our ancestors: practice makes perfect
Make a simple mirror image of their own to run a bunch of broken encountered problems
Learning docker mainly in the rookie tutorial https://www.runoob.com/docker/docker-container-usage.html
One point knowledge
The first port is a real machine, and the second port is a docker's
docker run -p 13138:13131 -d lastt
***************************************************************************************************
Knowledge Point II
We start your favorite java -jar jar package
But the command file on the docker, always occurs immediately after the start Ah hang
This is a summary of a blogger
https://blog.csdn.net/do_it_/article/details/80014321
Recent looking at how to make the container docker certain processes to run directly at the start, later found Dockerfile can run a command when the specified container vessel started.
CMD is specified, but each Dockerfile can only have a CMD command, if the specified number of CMD is specified, only the last one will be executed.
So I wanted a way to write a script, start multiple processes in the script, run the script in Dockerfile years.
Finally, prove that this method is feasible, a problem encountered in the course of the experiment, the container starts will stop immediately.
After checking the data:
Docker container while only manage a process, if the process exits the container will then withdrew, but this does not mean that the container can only run one process (other processes can run in the background), but not to make the container must have a foreground quit process.
Solution:
Finally, the script must use a process that is in the foreground mode without the process of the final & (& means running in the background), otherwise the vessel will exit.
----------------
Disclaimer: This article is CSDN blogger "do_it_ 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/do_it_/article/details/80014321
Encountered in learning docker docker container when a pit is no program running in the foreground when docker would think that this container does not work content will automatically close the container
Solution:
When writing dockerfile remember to perform a task to stay in the foreground, especially in doing the kind of general services running in the background such as mysql need to let him run in the foreground mysqld.service
This is a mysql pit and have not yet come across
***************************************************************************************************
Coming back to deploy
https://blog.csdn.net/dhaiuda/article/details/82228186
I was under the ride, but I made a silly project is port 13131, initial port mapping how and certainly this time, I was not any other port specified in the command where to start, then why would I want to start a docker port projects will change the spring
Really brain pumping
After the discovery solves the problem, this is a smooth,
I use this content https://www.jianshu.com/p/397929dbc27d bloggers in solving this problem
3. Write Dockerfile file
Docker Image # for springboot File RUN # VERSION 0.0.1 # Author: eangulee # base image using the Java the FROM the Java: 8 # of MAINTAINER eangulee <[email protected]> # VOLUME specifies the temporary directory is / tmp. # The effect is the host created under / var / lib / docker a temporary directory, and link to the container / tmp VOLUME / tmp # add the jar package to the vessel and renamed app.jar the ADD Demo -0.0.1 - SNAPSHOT.jar app.jar # jar package running the rUN the bash -C 'Touch /app.jar' EntryPoint [ "Java", "- Djava.security.egd = File: / dev /./ urandom", "- jar" , "/ app.jar"]
Under this interpretation configuration file:
VOLUME specify the temporary directory is / tmp. The effect is created in the host / var / lib under / docker catalog a temporary file, and link to the container / tmp. Reform step is optional, if it comes to the application file system is very necessary. / tmp directory is used to Docker persistent data folder, because the embedded Tomcat container Spring Boot using the default / tmp as the working directory
as "app.jar" added to the container jar file project
ENTRYPOINT implementation of the project app.jar. In order to shorten the Tomcat startup time, add a system property pointing to "/dev/./urandom" as Entropy Source
If the package is the first time, it will automatically download java mirror 8 as the base image, mirrored later when he will not be downloaded.