简体   繁体   English

Beanstalk 中的 commands 和 container_commands 配置键有什么区别?

[英]What is the difference between commands and container_commands configuration keys in Beanstalk?

When we setup Elastic Beanstalk extensions in.ebextensions当我们在 .ebextensions 中设置 Elastic Beanstalk 扩展时

I wonder what is the difference between commands and container_commands in Beanstalk configuration file keys.我想知道 Beanstalk 配置文件键中的commandscontainer_commands有什么区别。

My command is like this我的命令是这样的

container_commands:
  04_insert_app:
    command: "cat .ebextensions/insertapp_job.txt > /etc/cron.d/insertapp_job && chmod 644 /etc/cron.d/insertapp_job"
    leader_only: true

container_commands works fine. container_commands 工作正常。

commands: has error .ebextensions/insertapp_job.txt not found命令:找不到错误.ebextensions/insertapp_job.txt

The major difference between these two pieces is when in the Elastic Beanstalk deployment process they are run. 这两个部分之间的主要区别在于它们在Elastic Beanstalk部署过程中运行。

Commands 命令

These commands are run early in the deployment process, before the web server has been set up, and before your application code has been unpacked: 这些命令在部署过程的早期,在设置Web服务器之前,以及在解压缩应用程序代码之前运行:

The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted. 命令按名称按字母顺序处理,并在设置应用程序和Web服务器并提取应用程序版本文件之前运行。 1 1

By default, the commands run in the root user's home folder. 默认情况下,命令在root用户的主文件夹中运行。 This and various other pieces of EB's behavior can be changed via options (working directory, whether to continue on error, environment variables to pass to commands, etc.) that can be passed along with the command. EB和行为的各种其他部分可以通过选项(工作目录,是否继续出错,环境变量传递给命令等)来更改,这些选项可以与命令一起传递。

Container Commands 容器命令

These commands are run later in the deployment process, after the web server has been set up, and after your application code has been unpacked to the staging folder, but before your application has been "deployed" (by moving the staging folder to its final location): 这些命令在部署过程中稍后运行,在设置Web服务器之后,以及在将应用程序代码解压缩到暂存文件夹之后,但在应用程序“已部署”之前(通过将暂存文件夹移动到其最终版本)位置):

Container commands run after the application and web server have been set up and the application version archive has been extracted, but before the application version is deployed. 在设置应用程序和Web服务器并且已提取应用程序版本存档之后,但在部署应用程序版本之前,将运行容器命令。 Non-container commands and other customization operations are performed prior to the application source code being extracted. 在提取应用程序源代码之前执行非容器命令和其他自定义操作。 2 2

By default, these commands run in the staging folder, so that any changes you make to the current folder will persist once your application is deployed (the path will change though, so be careful about relative links!). 默认情况下,这些命令在暂存文件夹中运行,因此一旦部署了应用程序,您对当前文件夹所做的任何更改都将保留(虽然路径会发生变化,但请注意相关链接!)。

Container commands support all the same options as (non-container) commands, but they also support a "leader_only" option: 容器命令支持与(非容器)命令相同的所有选项,但它们也支持“leader_only”选项:

You can use leader_only to only run the command on a single instance, or configure a test to only run the command when a test command evaluates to true. 您可以使用leader_only仅在单个实例上运行该命令,或者将测试配置为仅在测试命令的计算结果为true时运行该命令。 Leader-only container commands are only executed during environment creation and deployments, while other commands and server customization operations are performed every time an instance is provisioned or updated. 仅限引导程序的容器命令仅在环境创建和部署期间执行,而每次配置或更新实例时都会执行其他命令和服务器自定义操作。 2 2

Here is an image from the aws doc Extending Elastic Beanstalk Linux platforms that illustrates the difference between commands and container_commands :这是来自 aws doc Extending Elastic Beanstalk Linux platforms的图像,它说明了commandscontainer_commands之间的区别:

平台-linux-扩展顺序

commands runs immedately after the application is downloaded during the initial step. commands在初始步骤下载应用程序后立即运行。 container_commands runs after Buildfile but before predeploy hooks during the configure step. container_commandsBuildfile之后但在配置步骤期间的predeploy挂钩之前运行。 This is assuming you are on Amazon Linux 2 using platform hooks.这是假设您在 Amazon Linux 2 上使用平台挂钩。

As an addition to @Tiro and @t10508hn answer I just want to clarify that both commands and container_commands are executed on the host machine. 作为@Tiro和@ t10508hn的补充,我只想澄清commandscontainer_commands都在主机上执行。

To execute commands within the docker container use the Dockerfile . 要在Dockerfile容器中执行命令,请使用Dockerfile

This was a point of confusion when I was had to execute a couple of commands with leader_only and assumed that container_commands were actually executed within the container. 当我不得不使用leader_only执行几个命令并假设container_commands实际在容器内执行时,这是一个混乱点。

I found my answer here aws offcial docs 我在这里找到了答案,这是官方的文件

commands : execute commands on the EC2 instance commands :在EC2实例上执行命令

container_commands : execute commands for your container container_commands :执行container_commands命令

暂无
暂无

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

相关问题 gcloud 命令行中这些命令集之间的实际区别是什么? - What's the actual difference between these set of commands in gcloud command-line? 使用“Container.GetItemLinqQueryable”和“Container.GetItemQueryIterator”有什么区别? - What is the difference between using "Container.GetItemLinqQueryable" and "Container.GetItemQueryIterator"? 在 aws 命令之间格式化 ansible 中的 json 标签 - formatting json tags in ansible between aws commands SAM 应用程序中的 PackageType: Image 和 build --use-container 之间有什么区别? - What is the difference between PackageType: Image and build --use-container in a SAM App? 在 App Engine 和 Compute Engine 中启动 docker 容器有什么区别? - What's the difference between launching a docker container in App Engine vs Compute Engine? 使用Elastic Beanstalk时,Docker在64bit Amazon Linux 2平台上运行和ECS在64bit Amazon Linux 2平台上运行有什么区别? - What's the difference between Docker running on 64bit Amazon Linux 2 and ECS running on 64bit Amazon Linux 2 platforms when using Elastic Beanstalk? getIdToken 和 getAppCheckToken 有什么区别? - What is difference between the getIdToken and getAppCheckToken? 如何使用 Fargate 在 AWS ECS 中正在运行的容器中运行命令 - How can I run commands in a running container in AWS ECS using Fargate gcloud 和 gsutil 有什么区别? - What is the difference between gcloud and gsutil? AzureMonitorTraceExporter 和 AzureMonitorSpanExporter 有什么区别? - What is the difference between AzureMonitorTraceExporter and AzureMonitorSpanExporter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM