Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does a docker-compose image publish a springboot project

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the docker-compose image how to release springboot project related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this docker-compose image how to release springboot project article, let's take a look.

Brief introduction

The Docker-Compose project is the official open source project of Docker, which is responsible for the rapid orchestration of Docker container clusters. Compose allows users to define a set of associated application containers as a project (project) through a separate docker-compose.yml template file (YAML format). The Docker-Compose project is written by Python and calls the API provided by the Docker service to manage the container. Therefore, as long as the operating platform supports Docker API, Compose can be used for orchestration management on it.

Docker-Compose divides the managed containers into three layers, namely, project, service and container. All the files under the Docker-Compose running directory (docker-compose.yml,extends files or environment variable files, etc.) form a project, which is the current directory name if no special project name is specified. A project can contain multiple services, and each service defines the images, parameters, and dependencies of the container. A service can include multiple container instances. Docker-Compose does not solve the problem of load balancing, so you need to use other tools to achieve service discovery and load balancing.

The project configuration file of Docker-Compose defaults to docker-compose.yml and can be customized through the environment variable COMPOSE_FILE or-f parameter, which defines multiple dependent services and the container in which each service runs.

Using a Dockerfile template file, you can easily define a separate application container. In the work, we often encounter the situation that multiple containers need to cooperate with each other to complete a task. For example, in order to implement a Web project, in addition to the Web service container itself, it is often necessary to add a back-end database service container and even a load balancing container.

Common command

Docker-compose introduction

The role of Compose is to "define and run applications for multiple Docker containers". With Compose, you can configure the services you apply in a configuration file (yaml format), and then use a single command to create and start all the services referenced in the configuration.

Two important concepts in Compose:

Service (service): a container for an application that can actually include several container instances running the same image.

Project (project): a complete business unit consisting of a set of associated application containers, defined in the docker-compose.yml file.

Docker compose installation steps

Download and install non-ROOT users via GitHub link remember to add sudo

Sudo curl-L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname-s)-$(uname-m)"-o / usr/local/bin/docker-compose

Give executable permissions to binary download files

Sudo chmod + x / usr/local/bin/docker-compose

Verify that it is installed

Docker-compose-version

Unloading

If it is installed in a binary package, just delete the binaries

Rm / usr/local/bin/docker-compose directory structure compose docker-compose.yml eureka Dockerfile eureka-server-2.0.2.RELEASE.jar user Dockerfile user-2.0.2.RELEASE.jar power Dockerfile power-2.0.2.RELEASE.jar example

The use of Compose is very simple, as long as you write a docker-compose.yml and then use the docker-compose command to operate. Docker-compose.yml describes the configuration of the container, while the docker-compose command describes the operation on the container.

1. Let's use a micro-service project to do a simple example. First, create a working directory for compose, and then create a jenkinsTest folder with executable jar packages and write a Dockerfile file. The directory structure is as follows:

The jar package uploaded by your test is stored in jenkins.

Docker-compose.yml

Version: '3.1' # here you need to specify the docker version of docker-compose: jenkinstest: # specify the service name # image: jenkinstest # specify the lowercase of the image name or you will get an error build:. / jenkinsTest # specify the path where the Dockfile is located: ports:-8099 ports # specify port mapping expose:-8099 # exposed service port

Dockerfile file

FROM adoptopenjdk/openjdk8:jdk8u-centos-nightly# author MAINTAINER lkz# image the port to be exposed. If you want to use the port, use-p effective EXPOSE 8099 COPY jenkinsTest.jar 11.jar # when executing the docker run command ENTRYPOINT ["java", "- jar", "11.jar"] to start the micro service after the image runs as a container. You can add the parameter-d to start docker-compose up-d in the background.

Using Docker Compose to orchestrate Spring Cloud microservices

Configuration is the same as above

Modify the docker-compose.yml file

Version: '3.3'services: eureka: image: eureka:v1 # specify the image name build:. / eureka # specify the path where the Dockfile is located ports:-8080 user: image: user:v1 build:. / user # specify the path where the Dockfile is located ports:-8081 power: image: power:v1 build:. / power # specify the path ports: -8082 8082 this is the end of the article on "how docker-compose images release the springboot project" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to release docker-compose image springboot project". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report