Micro Technology and Services container binding Docker --- (a)

series

Micro Technology and Services container binding -docker (a)
a container technology combined with micro-services -Kubernetes basic introduction (b)
the container of micro-services technology and binding -Pod Detailed (c)

Micro Services

Micro-service technology is mature now, in fact, nothing to say, just a concept, not a large, stand-alone project, a new concept and a single application development and deployment evolution, so there will not introduce more. There are too many open-source project that lets you easily play with micro-services, springcloud series, dubbo series even based on self-study and other communications netty series.

Communications, security, isolation, fuse downgrade, are micro keyword services, may not need any scene of micro-services. Micro-services framework will also inevitably result in the development, operation and maintenance costs increase

docker scene

But here introduce more docker, you can go to see the concept. docker is a container of, but not necessarily the best way to deployment. For business team or business clusters (micro-services) is not a lot, and more concerned about inter-regional communication program for exclusive use of cloud resources can be deployed, convenient and quick.

Early use docker, most of the scenes are for operation and maintenance, lightweight docker allows simple operation and maintenance of a revolutionary upgrade. And most of the room in the same rack group, each machine is equipped with a high, so use docker to run various services to seize the resources of a single machine. But when it comes to cloud or hybrid cloud, you will find a common system, even if it is more than a dozen micro-system services, use docker even k8s choreography, will greatly affect the efficiency of the development, operation and maintenance costs increase, there is no Stand-alone seize deployment (such as a java program occupied by one EC2 resources, without high with EC2 you can) to the convenient, specific reference system architecture bloggers blog ~

So for a business or from a team 0-1, the container does not need to consider the technology, but of course still have to learn.

Here Insert Picture Description
We can see that, in fact, the program itself is already a cloud of container virtualization technology. Combined docker and k8s, the more room for the unique IT companies, operation and maintenance will become lightweight. If the cloud or hybrid cloud, bloggers do not recommend extreme of self-built container, you can use cloud solutions

docker installed on mac

System Requirements

Docker for Mac minimum system requirements for the macOS 10.10.3 Yosemite, or Mac models after 2010, to be exact with Intel MMU virtualization, the minimum 4GB of memory.
If the system does not meet the requirements, you can install Docker Toolbox.

installation

Use Homebrew install
Homebrew The Cask has supported Docker for Mac, so you can easily use to install Homebrew Cask:

brew cask install docker

After the success of the small whale icon there, and his own docker login account, create an account to go on dockerHub, the mirror can be made up

docker usage is simple: development is complete packaged mirror image uploaded to the repository server and then execute the script pull the latest images, stop existing mirror service, and then delete the old image, start a new mirror service on the line ~

docker install linux

Reference https://www.jianshu.com/p/8b795475e3ce

Docker's commands

docker run -d -p 8080:80 --name webserver nginx —用docker启动一个nginx实例,nginx默认80端口。docker将端口映射成8080。服务器访问8080即可。这个服务名称是webserver
docker ps --查看当前运行的服务
docker ps -a --查看所有的服务
docker stop webserver --停止webserver这个服务
docker rm webserver --删除webserver这个服务
docker run -d -p 10002:10001 -e “spring.profiles.active=prod” --name demo luffy -e后面可以带环境变量。更好的适配应用的配置文件
docker build -f ./Dockerfile -t codemon/luffy-dev . 创建镜像,后面有那个点,如果Dockerfile在当前目录下, -f ./Dockerfile 可以去掉
docker run -d -p 10001:10001 -e “spring.profiles.active=qa” -e “eureka_ip=10.31.12.218” --name demo luffy 这里可以-e无限添加环境变量
docker logs -f -t --since=“2017-05-31” --tail=10 edu_web_1

–since : 此参数指定了输出日志开始日期,即只输出指定日期之后的日志。
-f : 查看实时日志
-t : 查看日志产生的日期
-tail=10 : 查看最后的10条日志。
edu_web_1 : 容器名称

springcloud结合docker部署

以springcloud微服务为例,如何让微服务和docker结合?springboot和cloud的脚手架这里就不介绍了
1.在你的项目中创建一个Dockerfile文件,内容:

FROM frolvlad/alpine-oraclejdk8:slim
RUN mkdir /docker/demo
RUN mkdir /docker/demo/logs
ADD ./target/app.jar /docker/demo/app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/docker/demo/app.jar"]

2.执行mvn package spring-boot:repackage docker:build
进行打包,达成可执行jar包,然后使用dockerFile构建镜像:

docker build -t codemon/app-dev .
末尾的 . 代码dockerFiler的路径,可以指定绝对路径

3.执行一个非常简单的脚本进行发布

docker stop app
docker rm app
docker rmi docker.io/codemon/app-dev
docker pull codemon/app-dev
docker run -d -p 10001:10001 -v /home/emper/logs/app:/app/logs -e "spring.profiles.active=qa" -e "mysql_ip=xx.xx.xx.xx" -e "mysql_user=qa" -e "mysql_passwd=qa" --name app docker.io/codemon/app-dev

意思就是在服务器上停止老的镜像并删除,下载最新的镜像并启动,-v是挂在磁盘,-e可以无限添加,用于环境变量设定

不需要sudo也可以执行docker命令:http://blog.csdn.net/he_wolf/article/details/37796285
docker换源: http://blog.csdn.net/zzy1078689276/article/details/77371782

最后

微服务严格意义上来说,可以说成是k8s容器化编排的一个子集,容器化或者微服务的魅力在于每个业务集群甚至个体都独立掌管子集内部的逻辑甚至DB,相互之间有极大的边界和隔离,这点类似于DDD。
Here Insert Picture Description
原谅我盗了一张图,可以看到,服务已经不再强依赖于一个共同语言,每个服务质检靠某种协议传输,如果有容器化的编排和管理,那么势必整个大的业务集群就相当于已给内置局域网VPC(参考博主的云架构系列)

Therefore greatly enhance the utilization of the container of the machine, to enhance the communication efficiency, it is not dependent on a cloud, or some machines, such hybrid cloud, private cloud, public cloud can be deployed anywhere layout.

Published 38 original articles · won praise 23 · views 10000 +

Guess you like

Origin blog.csdn.net/zl592886931/article/details/104262351