1 min read | by Jordi Prats
The AWS CLI is a command line interface for interacting with AWS services. To install it in an Alpine-based container we can use pip instead of going thru all the trouble of downloading a zip and install it by running some script.
To install it we'll need some python dependencies: python3 and py3-pip. Once we have them we just need to install the awscli module.
To avoid keeping cache files in the docker layers, we can run pip install using the --no-cache-dir flag. The Dockerfile for that will look like this:
FROM alpine:latest
RUN apk --no-cache add python3 py3-pip
RUN pip3 install --upgrade pip \
&& pip3 install --no-cache-dir awscli
Update: On the latest versions of alpine, you will run into the following error:
error: externally-managed-environment
You'll have to add an additional step to fix it, please refer to the post AWS CLI: Fix externally-managed-environment.
Posted on 09/02/2023