Get the App
SLTechnology News&Howtos  ›  Servers  › 

Can docker build java containers?

Shulou Source: shulou.com Published: 2022-06-01 02:39:23 10月18日 Update

Docker can build java container, I believe many inexperienced people can do nothing about it, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.

Can docker build java containers? Docker container can install Java development environment, first make sure that the machine has installed docker container and other software, that is, enter docker version in the console, docker version will appear. Need to install jdk, tomcat, nginx, installation package to the official website download on the line.

install the JDK

Extract JDK package:

tar -zxf jdk-7u71-linux-x64.tar.gz -C

If it's an rpm packet

rpm -ivh jdk-7u71-linux-x64.tar.gz

Then rename the folder

mv jdk1.7.0_71/ jdk/

Final configuration environment variables

vi ~/.bashrc

Add the following configuration at the end of the file:

export JAVA_HOME=/opt/jdkexport PATH=$PATH:$JAVA_HOME

Open/etc/profile with a text editor

Add at the end of the profile:

export JAVA_HOME=/usr/share/jdk1.6.0_14export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=.:$ JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Finally, use the source command to make the environment variable take effect:

source ~/.bashrcsource /etc/profile

Install Tomcat

Extract Tomcat package:

tar -zxf apache-tomcat-7.0.55.tar.gz

Then rename the Tomcat directory:

mv apache-tomcat-7.0.55/ tomcat/

Write a script to run when the container is started and start Tomcat. The process is as follows:

vi /root/run.sh

Then edit the script as follows:

#!/ bin/bashsource ~/.bashrcsh /opt/tomcat/bin/catalina.sh run

Note: You must load the environment first and then run Tomcat using Tomcat's run script

Finally, add execute permissions for running scripts:

chmod u+x /root/run.sh

install Nginx

First go to the official website to download the source package, pay attention to if gz

After downloading, extract the installation package:

tar -zxvf nginx-1.11.5.tar.gz

Then configure the installation variables, open the decompressed directory-execute the command

cd nginx-1.11.5

Finally, configure the installation environment, submit the Docker image, and start the container.

After reading the above, do you know how docker can build java containers? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Container environment script run configure content variable file command method more end directory program problem helpless for this reason for this reason skill Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB Redmi OPPO Reno Microsoft