Add this line to a Dockerfile to install and configure DogStatsD
in the container. Requires that apt-get
is available on the system.
This script will install curl
in your environment but not
remove it; you should uninstall it if you don't want it available
in the container.
These script uses md5sum
to validate all external scripts that are
downloaded, to prevent tampering or any other unexpected changes.
# BEGIN install local dogstatsd agent
# From: https://gist.github.com/JoshuaGross/a36ccc1a77d581e1daa143193a25535a
ENV DOCKER_DD_AGENT=yes AGENT_VERSION=1:5.12.3-1
RUN (/bin/bash -c "apt-get update && apt-get install -y curl && (curl https://gist.githubusercontent.com/JoshuaGross/a36ccc1a77d581e1daa143193a25535a/raw/5a9e747bd2292a5c43ae3cf1e40b5c822f55da86/dogstatsd-install.sh > dogstatsd-install.sh) && EXPECTED=\"88973ab95b97099f3274398f9ce59210\" && ACTUAL=(\$(md5sum dogstatsd-install.sh)) && (if [[ \"\$ACTUAL\" != \"\$EXPECTED\" ]]; then echo \"Incorrect md5 checksum for dogstatsd-install.sh, failing. Expected: \$EXPECTED. Actual: \$ACTUAL\"; exit 1; fi) && chmod +x dogstatsd-install.sh && ./dogstatsd-install.sh && rm dogstatsd-install.sh")
# END install local dogstatsd agent
md5 hash of dogstatsd-install.sh
: 88973ab95b97099f3274398f9ce59210
md5 hash of entrypoint.sh
: 833c48d970c84d4813dec4da0092c45a
md5 hash of supervisor.conf
: f7273b70b86d2cc0e40745fb3c77a42b
You must then start the dd-agent with a start script. It's recommended to start your own application in the same way:
#!/usr/bin/env bash
set -e
# Start the DataDog agent
echo "Start DogStatsD..."
/etc/dd-agent/entrypoint.sh supervisord -n -c /etc/dd-agent/supervisor.conf &
# Start app
echo "Start app..."
my-app &
# Don't exit until both other subprocesses have exited
# TODO: race them
wait