springcloud and docker micro Services Architecture combat - Notes

After the "micro-services those things," read, Spring boot and Spring Cloud relations straightened, Spring cloud the role of each module also understand.

However, the detailed use of relational Spring cloud and Docker, the relationship between Spring boot and Docker's, Spring cloud, or do not understand.

"Springcloud and docker combat micro Services Architecture" book, a total of 270, though not described in too deep, however, for the entry is a very good book, after all, not too thick book for entry use.

A total of 14 chapters of this book

The first chapter, micro Services Architecture Overview

The second chapter, Spring cloud Introduction

The third chapter, started using Spring cloud

Chapter IV, micro-service registration and discovery Eureka

Chapter V, Ribbon implement client load balancing

Chapter VI, Feign achieve REST calls

Chapter VII, Hystrix achieve fault tolerance

Chapter VIII, using the Zuul building micro gateway service

Chapter IX, the use of Spring Cloud Config unified management of micro-services configuration

Chapter X, Sleuth implement micro-tracking service

Chapter 11, Frequently Asked Questions summary

Chapter 12, Docker

Chapter 13, the service will run on the micro-Docker

Chapter 14, with Docker Compose choreography microService

Chapter I to Chapter 11 has a general understanding of, and therefore little to see.

Key to see the relationship between chapters 12, 13, understand springboot, SpringCloud, Docker, Docker Compose

 

Chapter 12, Docker Profile

Client、Images、Container、Registry、Docker Hub

The basic command Docker, because I've learned a docker basis, so this is no longer part of the record.

 

Chapter 13, the service will run on the micro-Docker

Build a Dockerfile file.

Docker build execution command, for example:

docker build -t nginx:my.

Dockerfile of common commands

ADD

ARG

ENV

CMD

EXPOSE

FROM

LABEL

MAINTAINER

RUN

USER

VOLUME

WORKDIR

 

Use

Use gradle packed project

Create documents Dockerfile project root directory, as follows:

FROM java:8
VOLUME /tmp
ADD build/libs/discovery-0.0.1-SNAPSHOT.jar /app.jar
# Modified file time attributes for the current system time
RUN bash -c 'touch /app.jar'
EXPOSE 8761
ENTRYPOINT java -jar /app.jar

docker build -t lakeslove/springcloud-blog-discovery:0.01 .

docker run -it -d -p 8761:8761 lakeslove/springcloud-blog-discovery:0.01

Access locahost: 8761

Pushed dockerhub

docker login

docker push lakeslove/springcloud-blog-discovery:0.01

Use plug-ins: docker-maven-plugin, gradle-docker-plugin and so on, a lot of plug-ins, but we kind of useless plug-in project, jenkins directly written in the script, and this is not being investigated.

 

Chapter 14, the use of micro-services orchestration DockerCompose

Compose is a tool used to define and run multiple applications Docker containers, ideal for development, testing, construction of CI workflow and other scenes.

Compose use basically three steps:

Use Dockerfile custom application environment, in order to reproduce the environment in any place

In docker-compose.yml defined in the file up the service application for each service run together in an isolated environment.

Run doker-compose up command, the whole application up and running

 

docker-compose.yml common commands

All references to environment variables docker-compose.yml .env file by setting default values file, detailed reference  https://www.cnblogs.com/sparkdev/p/9826520.html

Examples are as follows:

version: "3.3"
services:
  eureka:
    build: .
    ports:
      - "8761:8761"
  volumes:
    - /opt/data:/var/lib/mysql

build build, followed by Dockerfile path

ports function is similar to docker run -p

volumes mounted roll path is provided, typically as a route map (host: container)

volumes_from mounted volume from another service or container, may be read-only designated ro, rw write, read and write default rw

 

docker-compose common commands

build to build or re-build services.

kill to stop the specified service container, for example: docker-compose kill eureka

Log output logs to see services 

port print binding common port, such as: docker-compose port eureka 8761, so you can output eureka 8761 service port binding common port

ps lists all containers, for example: docker-compose ps

pull Mirror download service

rm delete the specified service containers, such as: docker-compose rm eureka

run execute a command on a service, such as: docker-compose run web bash

scale setting operation specifies the service number of containers, designated as service = num, examples: docker-compose scale user = 3 movie = 3

start start container specified service already exists, for example: docker-compose start eureka

stop Stops the container is running, for example: docker-compose stop eureka

up to build, create, re-create, start, connection container services, all connected to the service will start, unless they are already running.

docker-compose up command outputs all polymerization vessel, when the command exits, all containers will stop running in the background docker-compose up -d

 

docker-compse network settings

By default, Compose will create a network application, each vessel will join the service in the network, so that the container can be another container to access the network, not only that, the container also has a service name is hostname other container access.

By default, the network name of the application based on the Compose project name, and project name is based on directory docker-compose.yml name,

To change the project name, you can use --project-name logos or COMPOSE_PROJECT_NAME environment variables

The default is to bridge network architecture

 

Docker Compose, the difference between the Docker Swarm, Kubernetes:

Docker Docker Compose is based on a single master container layout tool, not to start the Docker containers on other hosts

Docker Swarm and Kubernetes is based Dcoker across a host of container management platform,

Docker Docker Swarm is a research and development company in competition with Kubernetes been losing ground, you do not have to learn.

So, a quick look at Docker Compose, in-depth study Kubernetes .

 

Guess you like

Origin www.cnblogs.com/lakeslove/p/11018227.html