Implementation steps for installing java environment in docker

Implementation steps for installing java environment in docker

This article is based on Linux centos8 to install docker and then pull the image to install various environments (tomcat, mysql, redis, etc.)

Install Tomcat on Docker

Download tomcat (you can specify the version number. Here the latest version is installed by default. For example, docker pull tomcat:9.0.37 )

[root@localhost ~]# docker pull tomcat:9.0.37

start up

[root@localhost ~]# docker run -d -p 8080:8080 --name tomcat01 tomcat

After running the above, it is found that the container http://192.168.32.128:3355/ (my example) cannot be accessed. Please see the analysis below

(Some containers of Alibaba, such as the tomcat image, have an empty webapp folder in webapps.dist, so be sure to copy the webapps.dist file to the webapps directory), as shown in the figure

#Enter the container directory [root@localhost ~]# docker exec -it tomcat01 /bin/bash
#Switch to the webapps.dist folder root@77e211d23175:/usr/local/tomcat# cd webapps.dist
#Copy file root@77e211d23175:/usr/local/tomcat# cp -r webapps.dist/* webapps

Re-visit http://192.168.32.128:8080/ (note that the port number is docker's)

By the way, you can use the modified tomcat as a new container to avoid copying files next time (e8c58b381b99 is the tomcat container id)

[root@localhost ~]# docker commit -m="Improve the files that webapps should have" -a="Zhang Xiaoxiang" e8c58b381b99 tomcat01:9.0.37

Install Elasticsearch with Docker

Official installation method https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docker.html

Download image

[root@localhost ~]# docker pull elasticsearch:7.9.0

To create a network, just give it a name, such as esnet

[root@localhost ~]# docker network create esnet

Single-node operation (no cluster configuration)

[root@localhost ~]# docker run -d --name elasticsearch --net esnet -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.9.0

Check whether it runs successfully (if it is still starting, it will report curl: (56) Recv failure: Connection reset by peer). Of course, you can also use a browser to test (note that the firewall is turned off)

[root@localhost ~]# curl localhost:9200

Startup successful return example

Docker installs mysql

Download image

[root@localhost dcoekrdata]# docker pull mysql:8.0.21

Run (-d background run, -v data mount -e environment configuration)

[root@localhost dcoekrdata]# docker run -d -p 3306:3306 -v /home/dockerdata/mysql/conf:/etc/mysql/conf.d -v /home/dockerdata/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root --name root mysql:8.0.21

Just use Navicat to test it.

Docker installation of RocketMq

Note that this requires installing 3 images to be OK, refer to the document

https://www.jb51.net/article/202117.htm

1: Install mq

[root@localhost dcoekrdata]# docker pull rocketmqinc/rocketmq:4.3.2

Run MQ Server

docker run -d -p 9876:9876 -v /home/dockerdata/mq/namesrv/logs:/root/logs -v /home/dockerdata/mq/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.3.2 sh mqnamesrv

2: Install broker

[root@localhost dcoekrdata]# docker pull rocketmqinc/rocketmq-broker:4.5.0-alpine-uid

Configuring the broker

[root@localhost dcoekrdata]# cd /home/dockerdata/mq
[root@localhost mq]# mkdir broker
[root@localhost mq]# cd broker/
[root@localhost broker]# touch broker.conf 
[root@localhost broker]# vi broker.conf

Configuration file (brokerIP1 = 192.168.32.128 is the public IP of the cloud server, or the IP of the Linux virtual machine. This article is just my example)

terName = DefaultCluster 
brokerName = broker-a 
brokerId = 0 
deleteWhen = 04 
fileReservedTime = 48 
brokerRole = ASYNC_MASTER 
flushDiskType = ASYNC_FLUSH 
brokerIP1 =192.168.32.128

Start the broker

docker run -d -p 10911:10911 -p 10909:10909 -v /home/dockerdata/mq/broker/logs:/root/logs -v /home/dockerdata/mq/broker/store:/root/store -v /home/dockerdata/mq/broker/broker.conf:/opt/rocketmq-4.3.2/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.3.2 sh mqbroker -c /opt/rocketmq-4.3.2/conf/broker.conf

3: Install the console rocketmq-console-ng

[root@localhost broker]# docker pull styletang/rocketmq-console-ng:1.0.0

Start the console ( note the IP address )

[root@localhost broker]# docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.32.128:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t styletang/rocketmq-console-ng:1.0.0

The installation was successful, and the test was as shown in the figure

This is the end of this article about the implementation steps of installing the Java environment in Docker. For more relevant content about installing the Java environment in Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Steps to build a Java environment using Docker
  • How to use Dockerfile to create a mirror of the Java runtime environment
  • Dockerfile deployment java web environment detailed explanation
  • Detailed explanation of using Docker to build a Java Web runtime environment
  • Using Dockerfile to build a Java web environment
  • Detailed explanation of building a front-end Java development environment with Docker
  • How to build a JAVA Tomcat operating environment under Docker
  • Explain how to use Docker to build a Java Web runtime environment
  • Detailed explanation of how to use Docker to build a simple Java development and compilation environment

<<:  A brief discussion on the VUE uni-app development environment

>>:  XHTML Getting Started Tutorial: XHTML Tags

Recommend

Getting Started Tutorial on GDB in Linux

Preface gdb is a very useful debugging tool under...

How to solve the Mysql transaction operation failure

How to solve the Mysql transaction operation fail...

Vue event's $event parameter = event value case

template <el-table :data="dataList"&...

Detailed explanation of the use of docker tag and docker push

Docker tag detailed explanation The use of the do...

A small problem about null values ​​in MySQL

Today, when testing the null value, I found a sma...

A brief discussion on common operations of MySQL in cmd and python

Environment configuration 1: Install MySQL and ad...

Implementation steps for installing FTP server in Ubuntu 14.04

Table of contents Install Software Management Ano...

Detailed explanation of SSH password-free login configuration under Linux

Assume there are two Linux servers A and B, and w...

Example of implementing skeleton screen with Vue

Table of contents Skeleton screen use Vue archite...

Summary of 10 common HBase operation and maintenance tools

Abstract: HBase comes with many operation and mai...

How to convert rows to columns in MySQL

MySQL row to column operation The so-called row-t...

Specific use of lazy loading and preloading in js

Delayed loading (lazy loading) and preloading are...

How to create https using nginx and Tencent Cloud free certificate

I have been studying how to get https. Recently I...