ecs-cli compose
Description
Manage Amazon ECS tasks with docker-compose-style commands on an ECS cluster.
Note
If you want to create Amazon ECS services with the ECS CLI, see ecs-cli compose service.
The ecs-cli compose command works with a Docker compose file to
create task definitions and manage tasks. At this time, the latest version of the
Amazon ECS CLI supports Docker compose
file syntax versions 1 and 2. By default, the command looks for a
compose file in the current directory, called
docker-compose.yml
; however, you can specify a different
file name or path to a compose file with the --file
option. This is
especially useful for managing tasks and services from multiple compose files at a
time with the ECS CLI.
The ecs-cli compose command uses a project name with the task
definitions and services it creates. When the CLI creates a task definition from a
compose file, the task definition is called
ecscompose-
. When
the CLI creates a service from a compose file, the service is called
project-name
ecscompose-service-
.
By default, the project name is the name of the current working directory. However,
you can specify your own project name with the project-name
--project-name
option.
Note
The ECS CLI can only manage tasks, services, and container instances that were created with the ECS CLI. To manage tasks, services, and container instances that were not created by the ECS CLI, use the AWS Command Line Interface or the AWS Management Console.
The following parameters are supported in compose files for the Amazon ECS CLI:
command
cpu_shares
dns
dns_search
entrypoint
environment
: If an environment variable value is not specified in the compose file, but it exists in the shell environment, the shell environment variable value is passed to the task definition that is created for any associated tasks or services.Important
We do not recommend using plain text environment variables for sensitive information, such as credential data.
env_file
Important
We do not recommend using plain text environment variables for sensitive information, such as credential data.
extra_hosts
hostname
image
labels
links
log_driver
log_opt
mem_limit
(in bytes)ports
privileged
read_only
security_opt
ulimits
user
volumes
volumes_from
working_dir
Important
The build
directive is not supported at this
time.
For more information about Docker compose file syntax, see the Compose file reference in the Docker documentation.
Syntax
ecs-cli compose [--verbose] [--file
compose-file
] [--project-name project-name
] [subcommand
]
[arguments
] [--help]
Options
Name | Description |
---|---|
|
Increase the verbosity of command output to aid in diagnostics. Required: No |
|
Specifies the Docker compose file to use. At this time, the latest version of the Amazon ECS CLI supports Docker compose file syntax versions 1 and 2. If the
Type: String Default: Required: No |
|
Specifies the project name to use. If the
Type: String Default: The current directory name. Required: No |
|
Show the help text for the specified command. Required: No |
Available Subcommands
The ecs-cli compose command supports the following subcommands:
- create
Creates an ECS task definition from your compose file.
- start
Starts a single task from the task definition created from your compose file.
- up
Creates an ECS task definition from your compose file (if it does not already exist) and runs one instance of that task on your cluster (a combination of create and start)
- ps
Lists all the containers in your cluster that were started by the compose project.
- scale
n
Scales the number of running tasks to the specified count.
- run [
containerName
] [command
] ... Starts all containers overriding commands with the supplied one-off commands for the containers.
- stop
Stops all the running tasks created by the compose project.
- service
[
subcommand
] Creates an ECS service from your compose file. For more information, see ecs-cli compose service.
- help
Shows the help text for the specified command.
Examples
Example 1
This example creates a task definition with the project name
hello-world
from the hello-world.yml
compose
file.
$ ecs-cli compose --project-name hello-world --file hello-world.yml create
INFO[0000] Using ECS task definition TaskDefinition=ecscompose-hello-world:5