简体   繁体   English

如何从AWS中的开发docker-compose.yml转到已部署的docker-compose.yml

[英]how to go from development docker-compose.yml to deployed docker-compose.yml in aws

I have the following docker-compose.yml: 我有以下docker-compose.yml:

version: '3'
services:
    server:
        build:
            context: ../../
            dockerfile: ./packages/website/Dockerfile
        command: yarn serve
        environment:
            PORT: 3000
            NODE_ENV: production
        restart: always
    nginx:
        build:
            context: ./
            dockerfile: ./nginx/Dockerfile
        command: nginx -c /etc/nginx/nginx.conf -g "daemon off;"
        depends_on:
            - server
        ports:
            - "80:80"
        restart: always

This works fantastically locally but now I want to deploy this to t2 micro or some other paid service but I don't know how I would go about it. 这在本地非常有效,但是现在我想将其部署到t2 micro或其他付费服务,但是我不知道该怎么做。

I think I would need to create a separate docker-compose.yml file which referenced images rather than physical Dockerfile(s) 我想我需要创建一个单独的docker-compose.yml文件,该文件引用图像而不是物理Dockerfile。

Can anyone shed any light on how I would go about this? 谁能阐明我该怎么做?

It's gonna work if you put the entire directory onto cloud (and keep the directory structure). 如果您将整个目录都放到云中(并保留目录结构),它将起作用。

If you somehow just want to upload the docker-compose.yml file to cloud without anything else, you need to modify it by removing the build field and adding an image: xxx field. 如果您只想将docker-compose.yml文件上传到云,而无需其他任何操作,则需要通过删除build字段并添加image: xxx字段来对其进行修改。

The question now becomes "how can I refer to an image in my docker-compose.yml file`. 现在的问题变成“我如何在docker-compose.yml文件中引用图像”。

Two ways to achieve this: 实现此目的的两种方法:

  1. Build the image and put it in some container registry, can be DockerHub, or a private one. 构建映像并将其放入某个容器注册表中,可以是DockerHub或私有的。 And refer to it with registry-url/image-name:image-tag . 并使用registry-url/image-name:image-tag引用它。 If you're using DockerHub, you can ignore the registry-url/ part. 如果您使用的是DockerHub,则可以忽略registry-url/部分。
  2. Build the image and scp to the cloud. 建立映像并scp到云。 And refer to it with image-name:image-tag . 并使用image-name:image-tag引用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Elastic Beanstalk 与 AMI2 和 docker-compose.yml - AWS Elastic Beanstalk with AMI2 and docker-compose.yml AWS Elastic Beanstalk 不支持 docker-compose.yml 吗? - is docker-compose.yml not supported in AWS Elastic Beanstalk? 我如何真正将 docker-compose.yml 部署到云端? - How do I really deploy docker-compose.yml to the cloud? 如何在 AWS Elastic Container Service 中使用现有的 docker-compose.yml 文件? - How to use existing docker-compose.yml file in AWS Elastic Container Service? docker-compose 显示所有不是在 docker-compose.yml 中定义的服务 - docker-compose displaying all services not the one defined in docker-compose.yml 错误:撰写文件“./docker-compose.yml”无效,因为:services.jenkins.networks 包含无效类型 - ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.networks contains an invalid type AWS ECS-CLI docker-compose.yml depends_on 错误“services.nginx.depends_on.0 必须是字符串” - AWS ECS-CLI docker-compose.yml depends_on error "services.nginx.depends_on.0 must be a string" 在AWS ECS中使用docker-compose.yml和ecs-params.yml文件以不同的Lauch类型和卷安装来运行多个任务定义 - Run multiple task-definition using docker-compose.yml and ecs-params.yml file in AWS ECS with different lauch type and volume mounting 将 Docker-Compose YML 部署到 AWS ECS - Deploy Docker-Compose YML to AWS ECS 每个 docker 撰写 yml 文件是否与 AWS ECS 容器兼容 - Does every docker compose yml file is compatible with AWS ECS containers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM