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)
Today I will introduce a small Javascript animati...
This article shares a blinds special effect imple...
In new projects, axios can prevent duplicate subm...
Unfortunately, the MYSQL_DATA_TRUNCATED error occ...
NC's full name is Netcat (Network Knife), and...
Table of contents 1. What are microtasks? 2. What...
Operating system: Win7 64-bit Ultimate Edition My...
Table of contents Configuration nfs server (nfs.s...
Table of contents Demand Background Why use Nginx...
Today, I am sharing the valuable experience of a ...
Website compatibility debugging is really annoyin...
When writing HTML code, the first line should be ...
Preview of revised version This article was writt...
Preface In project development, there are many wa...
error message: ERROR 1862 (HY000): Your password ...