Using Outrig with Docker
This guide covers how to use Outrig when your Go application runs inside Docker containers (as of Outrig v0.8.0)
Prerequisites
Before using Outrig with Docker, you must first install and run the Outrig monitor on your host machine (not inside the container). The Outrig server needs to be running locally to collect data from your containerized applications.
→ Follow the Quick Start guide to install and run Outrig on your host machine first.
Overview
When running Go applications in Docker containers, the Outrig SDK automatically detects the Docker environment and attempts to connect to
host.docker.internal:5005
to communicate with the Outrig server on your host machine. In most Docker setups, no additional configuration is needed.
Basic Setup
1. SDK Integration
Integrate the Outrig SDK into your Go application as usual:
import _ "github.com/outrigdev/outrig/autoinit"
The SDK will automatically detect the Docker environment and connect to the host machine.
2. Install Outrig Monitor in Container
You also need to install the Outrig binary inside your Docker container. If you are using an Alpine based image, add these lines to your Dockerfile:
# ---- START: Outrig Integration ---- RUN apk add --no-cache curl RUN curl -sf https://outrig.run/install.sh | sh # ---- END: Outrig Integration ----
Note
For Debian/Ubuntu or CentOS/RHEL images, you can typically omit the apk add
line, as curl is usually pre-installed.
To pin Outrig to a specific version (recommended for production), specify it like this:
# ---- START: Outrig Integration ----
RUN apk add --no-cache curl
RUN curl -sf https://outrig.run/install.sh | OUTRIG_VERSION=0.8.3 sh
# ---- END: Outrig Integration ----
Note: you can also download the Outrig .tar.gz, .deb, or .rpm files from our Github Releases Page and install them manually in your Dockerfile if you prefer not to use the install script.
Complete Example
Here's a complete Dockerfile example for a Go application with Outrig:
FROM golang:1.24-alpine # ---- START: Outrig Integration ---- RUN apk add --no-cache curl RUN curl -sf https://outrig.run/install.sh | sh # ---- END: Outrig Integration ---- WORKDIR /app # Cache dependencies for quick rebuilds COPY go.mod go.sum ./ RUN go mod download # Copy and build your Go application COPY . . RUN go build -o main . # Set the entrypoint to run your application EXPOSE 8080 CMD ["./main"]
That's it! Your containerized Go application will automatically connect to the Outrig server running on your host machine.