AWS CLI v2 in a Debian-flavored docker image


Context

The apt package manager doesn’t include aws cli version 2. As an alternative, we can follow the installation steps from Installing, updating, and uninstalling the AWS CLI version 2 on Linux

Advantages of v2

  • It doesn’t require a previous python installation. Each aws cli release contains a self-contained, embedded copy of Python
  • Support for newer AWS APIs in contrast with the v1 cli.

Dependencies

The aws cli depends on the following packages (which may be already present on your distribution):

  • groff
  • less
  • glibc

less and glibc are already include in the debian based image.

Implementation

Let’s see below how to install the v2 of the aws cli, using the debian docker image:

FROM debian:latest

# May be optional if these packages are installed already in the base image
RUN apt update && apt install -y curl unzip groff

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
	./aws/install

ENTRYPOINT ["aws"]

References

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.