aws-cli-dind
AWS CLI v2 + Docker CLI on Alpine — lightweight image for CI/CD workflows
10K+
A lightweight, multi-architecture Docker image combining AWS CLI v2 and Docker CLI built on Alpine.
This image is optimized for CI/CD pipelines where you need both AWS CLI and Docker commands without the overhead of installing Docker inside the AWS CLI image.
amd64 and arm64.docker run --rm mobeatsglobal/aws-cli-dind:latest aws --version
docker run --rm mobeatsglobal/aws-cli-dind:latest docker --version
Use this image as your build environment or CI step to streamline AWS and Docker workflows with a small, efficient base.
This is an example gitlab job for reference in the usage of this image to build and push to AWS ECR, and deploy in ECS
This example uses the following variables that should be defined either at the project level, group level or server level depending on your gitlab setup
AWS_ACCESS_KEY_ID = YOUR-AWS-SECRET-ACCESS-KEY
AWS_SECRET_ACCESS_KEY = YOUR-AWS-SECRET-ACCESS-KEY
AWS_REGION = YOUR-AWS-REGION
DOCKER_REGISTRY = YOUR-AWS-ACCOUNT-ID.dkr.ecr.YOUR-AWS-REGION.amazonaws.com
PROJECT = example
APP_NAME = backend
ECS_CLUSTER = YOUR-ECS-CLUSTER-NAME
ECS_SERVICE = YOUR-ECS-SERVICE-NAME
It uses aws ecr, aws ecs (and task definitions), so your user should at least have permisions for both of these services
variables:
AWS_DEFAULT_REGION: us-east-1
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
stages:
- build
- deploy
workflow:
rules:
- if: '$CI_COMMIT_TAG'
build:
stage: build
image:
name: mobeatsglobal/aws-cli-dind
entrypoint: [""]
tags:
- arm64 # This depends on your runner architecture, it supports both amd64 and arm64
services:
- name: docker:dind
alias: docker
before_script:
# Set up tools
- printf "\033[0Ksection_start:%s:set_up_tools\r\033[0K\033[36mSet Up tools\033[0m\n" "$(date +%s)"
- docker --version
- aws --version
# Wait for docker to be ready
- until docker info; do echo "Waiting for docker daemon..."; sleep 1; done
- printf "\033[0Ksection_end:%s:set_up_tools\r\033[0K\n" "$(date +%s)"
script:
# Login to ECR Repository
- printf "\033[0Ksection_start:%s:docker_login\r\033[0K\033[36mDocker login\033[0m\n" "$(date +%s)"
- aws ecr get-login-password | docker login --username AWS --password-stdin "$DOCKER_REGISTRY"
- DOCKER_REGISTRY_IMAGE="$DOCKER_REGISTRY/$PROJECT/$APP_NAME"
- printf "\033[0Ksection_end:%s:docker_login\r\033[0K\n" "$(date +%s)"
# Build Docker image and tag it as latest
- printf "\033[0Ksection_start:%s:build_image\r\033[0K\033[36mBuilding image\033[0m\n" "$(date +%s)"
- docker build -t "$DOCKER_REGISTRY_IMAGE:latest" -f Dockerfile .
- docker tag "$DOCKER_REGISTRY_IMAGE:latest" "$DOCKER_REGISTRY_IMAGE:$CI_COMMIT_TAG"
- printf "\033[0Ksection_end:%s:build_image\r\033[0K\n" "$(date +%s)"
# Push docker image
- printf "\033[0Ksection_start:%s:pushing_image\r\033[0K\033[36mPushing image\033[0m\n" "$(date +%s)"
- docker push "$DOCKER_REGISTRY_IMAGE:$DOCKER_TAG"
- docker push "$DOCKER_REGISTRY_IMAGE:$CI_COMMIT_TAG"
- printf "\033[0Ksection_end:%s:pushing_image\r\033[0K\n" "$(date +%s)"
deploy:
stage: deploy
image:
name: mobeatsglobal/aws-cli-dind
entrypoint: [""]
tags:
- arm64 #Since this just runs aws ecs commands, the architecture is indifferent, you can choose whichever you want
script:
# Deploy ECS Service
- printf "\033[0;32m✅ Deploying to ECS Service.\033[0m"
# Get Current Task Definition
- currentTaskDefinition=$(aws ecs describe-services --region $AWS_REGION --cluster $ECS_CLUSTER --services $ECS_SERVICE --query 'services[0].taskDefinition' | tr -d '"')
# Update service using current task definition, forcing new deployment
- aws ecs update-service --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --task-definition $currentTaskDefinition --force-new-deployment
Content type
Image
Digest
sha256:94666398d…
Size
70.4 MB
Last updated
7 days ago
docker pull mobeatsglobal/aws-cli-dind