IntroductionThe Docker-Compose project is an official open source project of Docker, responsible for realizing the rapid orchestration of Docker container clusters. Compose allows users to define a group of related application containers as a project through a single docker-compose.yml template file (YAML format). The Docker-Compose project is written in Python and calls the API provided by the Docker service to manage containers. Therefore, as long as the operating platform supports the Docker API, Compose can be used on it for orchestration management. Docker-Compose divides the managed containers into three layers: project, service, and container. All files in the Docker-Compose running directory (docker-compose.yml, extends files or environment variable files, etc.) form a project. If no special project name is specified, the current directory name is used. A project can contain multiple services, and each service defines the image, parameters, and dependencies of the container running. A service can include multiple container instances. Docker-Compose does not solve the problem of load balancing, so other tools are needed to achieve service discovery and load balancing. The default project configuration file of Docker-Compose is docker-compose.yml. You can customize the configuration file through the environment variable COMPOSE_FILE or the -f parameter. It defines multiple dependent services and the containers running each service. Common commands docker-compose introduce The role of Compose is to "define and run applications in multiple Docker containers." With Compose, you can configure your application's services in a configuration file (yaml format), and then use a single command to create and start all the services referenced in the configuration. Installation of Docker Compose There are many ways to install Compose. This article explains how to install it through the shell. If you are interested in other installation methods, Docker Compose installation stepsDownload and install through GitHub link. Non-ROOT users 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 the binary download file sudo chmod +x /usr/local/bin/docker-compose Verify installation docker-compose --version Uninstall If it is installed as a binary package, just delete the binary file rm /usr/local/bin/docker-compose Directory Structurecompose 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 Compose is very easy to use. You only need to write a docker-compose.yml file and then use the docker-compose command. docker-compose.yml describes the configuration of the container, while the docker-compose command describes the operation of the container. docker-compose.yml version: '3.1' #Here you need to specify the docker version corresponding to docker-compose services: jenkinstest: #Specify the service name#image: jenkinstest #Specify the image name in lowercase otherwise an error will be reportedbuild: ./jenkinsTest #Specify the path where the Dockfile is locatedports: - 8099:8099 #Specify port mapping expose: - 8099 #Exposed service port Dockerfile FROM adoptopenjdk/openjdk8:jdk8u-centos-nightly #AuthorMAINTAINER lkz # The port to be exposed by the image. If you want to use the port, use -p to take effect when executing the docker run command EXPOSE 8099 COPY jenkinsTest.jar 11.jar # Command executed after the image runs as a container ENTRYPOINT ["java","-jar","11.jar"] To start the microservice, you can add the parameter -d to start it in the backgrounddocker-compose up -d Orchestrate SpringCloud microservices using Docker ComposeModify the docker-compose.yml file as above version: '3.3' services: eureka: image: eureka:v1 #Specify the image name build: ./eureka #Specify the path where the Dockfile is located ports: - 8080:8080 user: image: user:v1 build: ./user #Specify the path where Dockfile is located ports: -8081:8081 power: image: power:v1 build: ./power #Specify the path where Dockfile is located ports: -8082:8082 This is the end of this article about the process analysis of docker-compose image publishing springboot project. For more relevant docker-compose publishing springboot project content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: DHTML objects (common properties of various HTML objects)
>>: Implementation of MYSQL (telephone number, ID card) data desensitization
Using Javascript to implement countdown to close ...
Solving the problem Bootstrap is a CSS framework ...
Recently, when I was drawing an interface, I enco...
Basics In a relational database, each data table ...
Table of contents Typical waterfall website Water...
Table of contents 1. Four concepts 1. JavaScript ...
mysql-8.0.19-winx64 downloaded from the official ...
Preface: Vue3 has been released for a long time. ...
Preface I encountered a Mysql deadlock problem so...
This article shares the specific code of the canv...
background A new server was added in the company,...
I joined a new company these two days. The compan...
Preface When it comes to database transactions, a...
1. First, generate the public key and private key...
I saw that Taobao’s webpage uses import, while man...