May 22, 2021 Docker From entry to practice
Get ready for the jdk, tomcat, and other software you need to put under the home directory and start a container
docker run -t -i -v /home:/opt/data --name mk_tomcat ubuntu /bin/bash
This command mounts the local home directory to the container's /opt/data directory, which is automatically created if it does not exist. Next is the basic configuration of tomcat, and once the jdk environment variable is set, put the tomcat program under /opt/apache-tomcat Edit the /etc/supervisor/conf.d/supervisor.conf file and add the tomcat item
[supervisord]
nodaemon=true
[program:tomcat]
command=/opt/apache-tomcat/bin/startup.sh
[program:sshd]
command=/usr/sbin/sshd -D
docker commit ac6474aeb31d tomcat
Create a new tomcat folder, create a new Dockerfile.
FROM mk_tomcat
EXPOSE 22 8080
CMD ["/usr/bin/supervisord"]
Create a mirror based on Dockerfile.
docker build tomcat tomcat
The steps are basically the same as tomcat, and here's a profile
supervisor.conf
[supervisord]
nodaemon=true
[program:weblogic]
command=/opt/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh
[program:sshd]
command=/usr/sbin/sshd -D
dockerfile
FROM weblogic
EXPOSE 22 7001
CMD ["/usr/bin/supervisord"]
At startup, use the
-v
parameter
-v, --volume=[] Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)
Map the local disk to the inside of the container, which changes in real time between the host and the container, so we just need to update the directory of the physical host to update the program and upload the code
Tomcat just needs to open multiple containers
docker run -d -v -p 204:22 -p 7003:8080 -v /home/data:/opt/data --name tm1 tomcat /usr/bin/supervisord
docker run -d -v -p 205:22 -p 7004:8080 -v /home/data:/opt/data --name tm2 tomcat /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7005:8080 -v /home/data:/opt/data --name tm3 tomcat /usr/bin/supervisord
Here's a look at the configuration of weblogic, and you know that weblogic has a domain concept. If you want to deploy in the regular administrator-node way, you need to write the startup scripts for administor server and node server in supervisord, respectively, which has the advantage of:
The disadvantages are:
Another approach is to install all the programs on top of adminiserver, and when you need to extend, start multiple nodes, which has the opposite advantages and disadvantages as the last one. (This is recommended for deploying development and test environments)
docker run -d -v -p 204:22 -p 7001:7001 -v /home/data:/opt/data --name node1 weblogic /usr/bin/supervisord
docker run -d -v -p 205:22 -p 7002:7001 -v /home/data:/opt/data --name node2 weblogic /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7003:7001 -v /home/data:/opt/data --name node3 weblogic /usr/bin/supervisord
This allows the configuration to be done by using nginx for load balancing at the front end