docker-compose 拉取镜像并发布镜像

x33g5p2x  于2021-11-18 转载在 Docker  
字(3.1k)|赞(0)|评价(0)|浏览(1014)

docker compose 定义

compose 用于定于和运行多容器docker应用程序的工具,通过compose,可以使用YML文件来配置应用程序需要的所有服务;使用一个命令可以从yml文件配置中创建并启动所有服务。

compose的使用步骤

1、使用dockerfile定义应用程序的环境
2、使用docker-compose.yml定义构成应用程序的服务
3、执行docker-compose up 命令零启动并运行整个应用程序

定义docker_compose.yml

version: "3"
services:
  api:
    image: "xxxxxxx/xxxxx${IMAGE_TAG}"
    container_name: XXXXXX-api
    restart: always
    network_mode: "host"
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    volumes:
      - /XXXXX:/XXXXXX:rshared
      - ${XXX_MNT_DIR}:${XXX_MNT_DIR}:rshared
      - ${XXX_SERVICES_DIR}/XXXX/api/provisioning:${XXXX_SERVICES_DIR}/XXX/api/provisioning
      - ${XXX_SERVICES_DIR}/XXX/api/logs:/var/log/xxx
      - ${XXX_SERVICES_DIR}/xxx/api/data:/root/h2
      - /etc/resolv.conf:/etc/resolv.conf:ro
      - /home/xxx/.ssh/id_rsa:/home/xxx/.ssh/id_rsa:ro
    environment:
      - api.ldap.home-directory=${LDAP_USER_HOME_DIRECTORY}
      - api.ldap.login-shell=${LDAP_USER_LOGIN_SHELL}
      - api.version=${API_VERSION}
      - api.deployMode=PUBLIC
      - api.authProvider=${AUTH_PROVIDER}
      - api.licenseMonitor=${LICENSE_MONITOR}
      - api.fsCloudCode=${FS_CLOUD_CODE}
      - api.cloudVendor=${CLOUD_VENDOR}
      - security.authProvider=${AUTH_PROVIDER}
      - cloud.enabled=false
      - xxx.username=${FASTONE_SERVICE_ACCOUNT}
      - xxx.password=${FASTONE_SERVICE_PASSWD}
      - cluster.storageInfos[0].device=${CLUSTER_STORAGEINFOS_DEVICE}
      - cluster.storageInfos[0].fsType=${CLUSTER_STORAGEINFOS_FSTYPE}
      - cluster.storageInfos[0].dir=${CLUSTER_STORAGEINFOS_DIR}
      - cluster.storageInfos[0].option=${CLUSTER_STORAGEINFOS_OPTION}
      - cluster.storageInfos[0].username=${CLUSTER_STORAGEINFOS_USERNAME}
      - cluster.storageInfos[0].password=${CLUSTER_STORAGEINFOS_PASSWORD}
      - cluster.storageInfos[1].device=${CLUSTER_STORAGEINFOS_CIFS_DEVICE}
      - cluster.storageInfos[1].fsType=${CLUSTER_STORAGEINFOS_CIFS_FSTYPE}
      - cluster.storageInfos[1].dir=${CLUSTER_STORAGEINFOS_CIFS_DIR}
      - cluster.storageInfos[1].option=${CLUSTER_STORAGEINFOS_CIFS_OPTION}
      - cluster.storageInfos[1].username=${CLUSTER_STORAGEINFOS_CIFS_USERNAME}
      - cluster.storageInfos[1].password=${CLUSTER_STORAGEINFOS_CIFS_PASSWORD}
      - spring.ldap.urls=${LDAP_URI}
      - spring.ldap.password=${LDAP_PASSWORD}
      - api.trial-mode=${TRIAL_MODE}
      - api.maxFileSize=${MAX_FILE_SIZE}
    depends_on:
      - db
  XXXservice:
    image: "XXXXXXXX/XXXservice${XXXXX_IMAGE_TAG}"
    container_name: XXXXX
    restart: always
    network_mode: "host"
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "5"
    environment:
      - fastone.XXXX-stack.strategy=XXXX
      - fastone.XXXX-stack.level=standard
      - API_USERNAME=${XXXX}
      - API_PASSWORD=${XXXX}
      - XX.global.api.username=${XXX}
      - XX.global.api.password=${XXX}
      - XX.service-users[0].username=${XX}
      - XX.service-users[0].password=${XX}
      - jasypt.encryptor.password=${JASYPT_ENCRYPTOR_PASS}
    volumes:
      - ${XX}/XX/XX/logs:/var/log/fastone
      - ${XX}/XX/XX/data:/root/h2
      - /etc/resolv.conf:/etc/resolv.conf:ro
      - /XX/data-migrate:/XX/data-migrate
      - ${XX}/billing:/XX/billing:rshared
    ports:
      - "50210:50210"
      - "50121:50121"
    depends_on:
      - db

批量拉取镜像的命令

docker-compose -f fastone_cloud.yml pull

单个拉取镜像的命令

docker-compose -f fastone_cloud.yml pull 服务名称

删除服务的命令(部署新的服务)

docker-compose -f fastone_cloud.yml rm -fs 服务名称
 
docker-compose -f fastone_cloud.yml up -d 服务名称

相关文章