1. Install DockerFirst open the Linux environment and enter the following command to install: Install yum install docker Check whether the installation is successful docker --version #Start systemctl start docker If the download is very slow, you can switch to the domestic Alibaba Cloud image to download: Change the image source sudo vim /etc/docker/daemon.json The content is as follows: { "registry-mirrors": ["https://m9r2r2uj.mirror.aliyuncs.com"] } Save and exit, restart Docker: systemctl restart docker 2. Install RedisFirst, search for redis in DockerHub. Click to enter the details page. Scroll down to see how to use it. If you need to select a specific version, there are Supported tags for us to choose from. Then, if you want to pull the latest version, scroll down to the command tutorial as follows: Pull the redis image docker pull redis View local redis image docker images Run redis docker run --name myredis -p 6379:6379 -d redis redis-server --appendonly yes
3. Install MySQLPull down the MySQL image: docker pull mysql:5.7.27 Docker runs MySQL: docker run --name mymysql -e MYSQL_ROOT_PASSWORD=admin -d -p 3306:3306 mysql:5.7.27 4. Install RabbitMQIt can be done with one line of command. Note that RABBITMQ_DEFAULT_PASS=password means setting the password. This line of command has secretly performed operations such as pulling down the image: docker run -d --hostname my-rabbit --name myrabbit -e RABBITMQ_DEFAULT_USER=root -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 rabbitmq:management 5. Install ElasticSearchThe pull-down mirror operation is omitted: start up: docker run -p 9200:9200 -p 9300:9300 -d --name es_643 elasticsearch:6.4.3 Enter the image: docker exec -it es_643 /bin/bash Install the Chinese word segmentation plugin: ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.3/elasticsearch-analysis-ik-6.4.3.zip Exit and restart the image exit docker restart es_643 6. Build the Docker image of the projectWe use the command to pull the project from GitHub: Drop-down items (eblog): clone https://github.com/MarkerHub/eblog.git Go into the folder: cd eblog Pack: mvn clean package -Dmaven.test.skip=true Upload the compiled jar package to the Linux server! Next, write DockerFile, which can build our packaged jar package code into an image: FROM java:8 EXPOSE 8080 VOLUME /tmp ENV TZ=Asia/Shanghai RUN ln -sf /usr/share/zoneinfo/{TZ} /etc/localtime && echo "{TZ}" > /etc/timezone ADD eblog-0.0.1-SNAPSHOT.jar /app.jar RUN bash -c 'touch /app.jar' ENTRYPOINT ["java","-jar","/app.jar"]
Next, we install Dockerfile and use DockerFile to build eblog-0.0.1-SNAPSHOT.jar into a mirror: Build the image docker build -t eblog . View docker images After this step is completed, we can complete the preparation work. Next, we will start our project directly. 7. Run the project image to complete the project startupThe command is as follows: docker run -p 8080:8080 -p 9326:9326 --name eblog --link es_643:ees --link myrabbit:erabbit --link mymysql:emysql --link myredis:eredis -d eblog
View eblog print log: docker logs -f eblog So far the project has run successfully! Notice: Using DockerCompose is easier This is the end of this article about the introduction of Docker rapid deployment of SpringBoot project. For more relevant Docker deployment SpringBoot content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: JSONP cross-domain simulation Baidu search
>>: CSS pseudo-class: empty makes me shine (example code)
system: VMTOOLs Download: Link: https://pan.baidu...
Docker is an open source engine that makes it eas...
Let me briefly describe some common basic graphic...
For example: <u> This has no ending characte...
Introduction to vi/vim They are both multi-mode e...
Solution: Add the following code in <head>: ...
This article example shares the specific code of ...
From the backend to the front end, what a tragedy....
This article records the installation and configu...
Introduction to common Dockerfile instructions in...
Slideshows are often seen on web pages. They have...
When processing batch updates of certain data, if...
This article shares the specific code of JavaScri...
Table of contents 1. Create a watermark Js file 2...
Table of contents 1. Import files 2. HTML page 3....