Docker installation (0.7.0 or later)
Apply WhaTap monitoring to Go applications deployed as Docker images. Download two installation files to the same directory as your Dockerfile, then add one to the build stage and the other to the runtime stage.
Tip
Before starting the installation, prepare the following information:
- WhaTap project access key (check from [Project menu] > [Management] > [Agent installation])
- WhaTap collection server IP address
Write the Dockerfile
Download both installation files to the same directory as your Dockerfile. On ARM64, replace every amd64 with arm64 in the commands below and in the Dockerfile.
wget https://repo.whatap.io/golang-apm/0.7.0/whatap-golang-apm-0.7.0-linux-amd64.tar.gz
wget https://repo.whatap.io/golang-apm/0.7.0/whatap-go-0.7.0-linux-amd64.tar.gz
# Build stage: Go 1.26 or 1.27
FROM golang:1.26 AS build
ADD whatap-golang-apm-0.7.0-linux-amd64.tar.gz /opt/
ENV PATH=/opt/whatap-golang-apm-0.7.0-linux-amd64/bin:$PATH
WORKDIR /src
COPY . .
RUN whatap-go-inst go build -o /out/myapp .
# Runtime stage: Go not required
FROM debian:bookworm-slim
ADD whatap-go-0.7.0-linux-amd64.tar.gz /opt/
COPY /out/myapp /app/myapp
ENV WHATAP_HOME=/app
WORKDIR /app
CMD ["/bin/sh", "-c", "/opt/whatap-go-0.7.0-linux-amd64/bin/whatap-daemon start && exec ./myapp"]
Build and run the image
whatap.conf contains the access key, so do not include it in the image. Mount it when you run the container. If whatap.conf is in the project directory, also add it to .dockerignore.
docker build -t myapp .
docker run -v "$PWD/whatap.conf:/app/whatap.conf:ro" myapp
For how to write whatap.conf, see General installation.