1

参考 周立 《Spring cloud 与Docker 微服务实战》

安装compose

官方文档

sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose

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

$ docker-compose --version

安装自动补全工具

curl -L https://raw.githubusercontent.com/docker/compose/1.18.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

编写docker-compose.yml


# 表示该文件使用的是version 2 file format
version: '2'

services:
    # 指定服务名称
    eureka:
      # 指定服务所使用的镜像
      image: b/eureka:1.0
      ports:
        - "8761:1111"
    api-server:
      image: b/api:1.0
      links:
        - eureka:discovery
    config-server:
      image: b/config:1.0
      ports:
        - "7000:7001"
~                                                                                                                                                                                                                                                                            
~                

docker-compose up 启动
docker-compose up --force-recreate 清空缓存,强制重新构建并启动
docker-compose down 停止
docker-compose restart api-server 重启一个服务;服务名称来自于docker-compose.yml里的定义


170901
100 声望0 粉丝

不会写文章,只会记笔记