What is docker-aws
Docker image for running the Amazon Web Services Command Line Interface and s3cmd. It creates a Docker image containing all dependencies needed to run
s3cmd. That way, you can run these tools in a Docker container without setting the dependencies on the host system.
How to use
There are specific CLI tools within the full range of the AWS CLI tool chain. Each of these has been mapped to a branch and tag so if you only need a specific CLI tool and/or have image size concerns there is something here to meet your needs. If you want all the AWS tool goodies, i.e. AWS CLI, RDS CLI, and S3CMD, then select the
master branch with the
latest tag in Docker Hub. Below are the mappings and usages:
|GitHub Branch||Docker Tag||Size (MB)||Usage Example|
The master/latest starts a
bash shell so you can use whatever tool you need. For the other containers they will start with the
--version flag which shows the version for the respective CLI tool. Simply specify whatever options you need for the respective tool (this will replace the default
Build from Source
Make sure Docker is installed.
Clone docker-aws from GitHub
git clone https://github.com/cgswong/docker-aws.git
Build the docker image
cd docker-aws docker build -t [your_name]/aws:latest .
Run a docker container with that image
docker run -it [your_name]/aws:latest
There are three primary methods for setting up your AWS credentials:
- Run the setup using the container, i.e. when you run the CLI tools for the first time, you need to configure the aws cli with your AWS credentials. For example:
/ # aws configure AWS Access Key ID [None]: [YOUR_AWS_ACCESS_KEY_ID_HERE] AWS Secret Access Key [None]: [YOUR_AWS_SECRET_ACCESS_KEY_ID_HERE] Default region name [None]: [YOUR_AWS_REGION_HERE] Default output format [None]: [YOUR_AWS_OUTPUT_FORMAT_HERE]
/root/.awshas been exposed within the image for external access. Therefore you can mount the AWS credential file to the container:
docker run --volume ~/.aws:/root/.aws cgswong/aws:latest aws [some_command]
By configuring your EC2 instances to make use of IAM Roles, the AWS CLI tools can then transparently make use of this role. Note however, that not all CLI tools can currently leverage this functionality, namely some of the RDS tools.