简体   繁体   中英

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

I have the following 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.

I think I would need to create a separate docker-compose.yml file which referenced images rather than physical Dockerfile(s)

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.

The question now becomes "how can I refer to an image in my docker-compose.yml file`.

Two ways to achieve this:

  1. Build the image and put it in some container registry, can be DockerHub, or a private one. And refer to it with registry-url/image-name:image-tag . If you're using DockerHub, you can ignore the registry-url/ part.
  2. Build the image and scp to the cloud. And refer to it with image-name:image-tag .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM