what is difference between commands and container commands in elasticbean talk

青春壹個敷衍的年華 提交于 2019-12-03 04:19:54

The major difference between these two pieces is when in the Elastic Beanstalk deployment process they are run.

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:

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.1

By default, the commands run in the root user's home folder. 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.

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):

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. Non-container commands and other customization operations are performed prior to the application source code being extracted.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:

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 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

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.

To execute commands within the docker container use the 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.

I found my answer here aws offcial docs

commands: execute commands on the EC2 instance

container_commands: execute commands for your container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!