To deploy multiple tomcat services with DockerFile on the Docker container

  • 2021-09-16 08:32:40
  • OfStack


[admin@JD ~]$ cd opt

# Enter opt in the root directory


[admin@JD opt]$ mkdir web

# Create an Web folder


[admin@JD web]$ cd web/

# Enter the web folder


[admin@JD web]$ touch Dockerfile

# Create 1 Dockerfile folder name can't be wrong. It must be this name. No, it can't be detected


Upload tomcat and jdk to Web folder using 3-party tools


[admin@JD web]$ vim Dockerfile

# Edit the file and write the following

FROM centos
ADD ./apache-tomcat-7.0.88.tar.gz /root
ADD ./jdk-7u80-linux-x64.tar.gz /root
ENV JAVA_HOME /root/jdk1.7.0_80
ENTRYPOINT /root/apache-tomcat-7.0.88/bin/ && tail -F /root/apache-tomcat-7.0.88/logs/catalina.out

Resource download

FROM Command, Usage, FROM < image > : < tag > The FROM command tells docker which (distribution) image we build is based on

ENV Command, Usage, ENV < key > < value > The ENV command is mainly used to set the environment variables of the container runtime

ADD Command, Usage, ADD < src > < dest > ADD is primarily used to add files from the host machine to the image


[admin@JD web]$ docker build -t test/centos:tomcat-centos --rm=true .

#-t Specify resource name customization

# --rm=rtue Reduces non-specified file generation

# Automatically build later and download 1 files. There may be a request timeout problem


[admin@JD web]$ docker run -d -p 9090:8080 fe8d

# Start tomcat and map port 8080 to the first 4 bits of 9090 fe8d resource ID


[admin@JD web]$ docker run -d -p 9091:8080 fe8d

# Start the 2nd tomcat port without conflict! !

10. Open the browser server ip + port number and you will see the cat # docker will automatically add firewall rules. I use iptables firewall

Simple build dockerflie file complete!

Additional knowledge: Building Open Source Object Store within docker (minio)

Some time ago, I did a project. Customers can't get data to the external network, so they can only build OSS object storage through the internal network. We rely on the platform of polar channel to do business. They adopted s3 standard and adopted minio to build an open source OSS object storage space, which is actually very simple

docker pull minio/minio Pulling Mirrors from Warehouse

docker run -p 9000:9000 --name minio1
-v /mnt/data:/data
-v /mnt/config:/root/.minio
minio/minio server /data


Let's talk about asking what to choose minio

(1) The support of C + + interface is required. Since s3 standard is adopted, Amazon's aws can be used

(2) This is a lightweight, highly concurrent solution

(3) Compared with FastDFS or hdfs, the advantage is that it can reserve 1 set for the feasibility of the previous demonstration

Post the encapsulation of C + + and the encapsulation of java later

Related articles: