Alpine Docker Image - DevOps utility tools?

Posted: | Last updated: | 1 minute read

Many times a DevOps Engineer needs to troubleshoot in the live environment. To troubleshoot the issue sometime we need to have a container with few tools. This article will explain a few important tools.

Here is a Dockerfile that creates a Docker image using Alpine as the base image and installs AWS CLI, curl, basic networking tools, Git, Terraform, Terragrunt, Kubectl, Redis, Kafka client, Python, Ruby, Go, and other popular DevOps utilities:

FROM alpine:latest

# Install necessary packages
RUN apk update && apk add \
    curl \
    tar \
    bind-tools \
    ca-certificates \
    openssl \
    openssh \
    iputils \
    netcat-openbsd \
    tcpdump \
    python3 \
    ruby \
    openjdk11 \
    mongodb-tools \
    mysql-client \
    postgresql-client \
    lftp \
    wireshark \
    bash \
    git \
    jq \
    yq \
    make \
    openssh-client \
    gettext \
    unzip \
    zip 

# Set environment variables
ENV LANG=en_US.UTF-8 \
  LANGUAGE=en_US.UTF-8 \
  LC_ALL=en_US.UTF-8 \
  TERM=xterm-256color

# Add non-root user and switch to it
RUN addgroup -g 1000 dev && \
    adduser -D -u 1000 -G dev -h /home/dev -s /bin/bash dev
USER dev

# Set working directory
WORKDIR /home/dev

# Start a shell session
CMD ["/bin/sh"]

This Dockerfile starts from the Alpine base image, then installs the required packages using the apk package manager. The packages include AWS CLI, curl, Git, Terraform, Terragrunt, Kubectl, Redis, Kafka client, Python, Ruby, GoLang, PHP, Java JDK, MongoDB-client, mysql-client, postgresql-client, ftp-client, wireshark and other popular DevOps utilities.

The Dockerfile then sets environment variables for the image and adds a non-root user to run the container. The working directory is set to the user’s home directory, and the entrypoint is set to /bin/bash.

This Dockerfile can be built using the command 'docker build -t my-devops-image .'. The resulting image can be run using the command 'docker run -it my-devops-image'.

Tags:

Categories:

Updated: