Installing the AWS CLI in an Alpine Docker Container

alpine awscli pip

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

Posted on 09/02/2023