Introducing our new CEO Don Johnson - Read More

amazon/aws-cli

Verified Publisher

By Amazon Web Services

Updated about 16 hours ago

Universal Command Line Interface for Amazon Web Services

Image
Developer Tools
313

1B+

Amazon Web Services Command Line Interface (AWS CLI)

This is a Docker image for the AWS CLI. It is a unified command line tool to interact with AWS services and manage your AWS resources.

NOTE: This image is only supported for the AWS CLI v2

Tags

There are two sets of supported tags:

  • latest - This corresponds to the latest released version of the AWS CLI. There are no backwards compatibility guarantees in relying on the latest tag. See notes on backwards compatibility for more information.

  • <major.minor.patch> - This corresponds to each released version of the AWS CLI. For example to use version 2.0.6 of the AWS CLI, use the tag 2.0.6. These tags are immutable as they will only ever be pushed to once upon release of a particular version of the AWS CLI.

Docker CLI usage

The AWS CLI can be executed from the Docker CLI with the docker run command:

$ docker run --rm -it amazon/aws-cli --version

This command will print out the version of the AWS CLI being used in the container. Note that the aws executable was not specified in the docker run command because the entrypoint for the image is defined as the aws executable.

For any AWS CLI command, you can run its help command to get help information about the command:

$ docker run --rm -it amazon/aws-cli help

In order to run a command that makes an AWS API call, credentials and configuration may need to be shared from the host system to the container. Assuming credentials and configuration are being set in the ~/.aws/credentials and ~/.aws/config file on the host system, they can be shared by mounting the ~/.aws directory to the /root/.aws directory of the container:

$ docker run --rm -ti -v ~/.aws:/root/.aws amazon/aws-cli s3 ls

For some AWS CLI v2 commands, you'll want to either read files from the host system in the container or write files from the container to the host system. This can be accomplished by mounting to the container's /aws directory:

$ docker run --rm -ti -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli s3 cp s3://aws-cli-docker-demo/hello .

The /aws directory is the working directory for the image and is reserved for the user. See notes on interfaces for more information.

In order to shorten the length of docker commands, you can add the following alias:

$ alias aws='docker run --rm -ti -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli'

This will allow you to run the AWS CLI v2 from within a Docker container as if it was installed on the host system:

$ aws --version

Notes on interfaces and backwards compatibility of Docker image

  • The only tool supported on the image is the AWS CLI. Only the aws executable should ever be directly executed. For example even though less and groff are explicitly installed on the image, they should not be executed directly outside of an AWS CLI command.

  • The /aws working directory is user controlled. The image will not write to this directory, unless instructed by the user in running a AWS CLI command.

  • There are no backwards compatibility guarantees in relying on the latest tag. For example theoretically, any of the following changes could happen between updates to latest tag:

    • A specific tool (e.g. less or groff) is removed from the image.

    • The base image is updated (e.g. change from Amazon Linux to Alpine Linux)

    • A new major version of the AWS CLI is published (e.g. an AWS CLI v3)

  • In order to guarantee backwards compatibility, users must pin to a specific <major.minor.patch> tag as those tags are immutable; they will only ever be pushed to once upon release of a particular version of the AWS CLI.

General AWS CLI usage

For information on general usage of the AWS CLI, please refer to the:

Source code

The source code for the AWS CLI can be found at its GitHub repository. The Docker image is built using the Linux exectuable installer for the AWS CLI v2 and the following Dockerfile.

Feedback

To file any feature requests or report any issues related to this Docker image, please open an issue on the GitHub repository for the AWS CLI.

Docker Pull Command

docker pull amazon/aws-cli