如何在Docker Compose期间运行`aws s3 sync`?

huangapple go评论62阅读模式
英文:

How run `aws s3 sync` during docker compose?

问题

以下是aws s3同步命令的代码片段:

version: '3.8'
services:
  amazon-aws-cli-download-test-data:  
    image: amazon/aws-cli:2.13.0 # <- 今天的最新版本
    command:
      - s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_REGION
    volumes:
      - './test-data/s3:/s3'

错误信息:

aws: error: argument command: Invalid choice, valid choices are:

s3命令是AWS CLI中最古老且肯定存在于所有AWS CLI版本中的命令。出了什么问题?如何在容器启动期间执行一些S3同步操作?

英文:

Here is snippet for aws s3 sync command:

version: &#39;3.8&#39;
services:
  amazon-aws-cli-download-test-data:  
    image: amazon/aws-cli:2.13.0 # &lt;- newest version for today
    command:
#       | `aws` main command was also tried and error was the same
#      \/ 
#     - aws s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
      - s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_REGION
    volumes:
      - &#39;./test-data/s3:/s3&#39;

The error:

aws: error: argument command: Invalid choice, valid choices are:

The s3 command is the oldest that definitely present in all aws cli's. What is wrong? How execute some s3 syncing during containmer start up?

答案1

得分: 0

更改为:

命令:s3同步 s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete

问题已修复。

英文:

Changes to

command: s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete

fixed the issue

huangapple
  • 本文由 发表于 2023年7月10日 23:45:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定