I am having a problem starting a docker container with statsd sevice with some ruby script. It is a simple container from this github page - https://github.com/morganjbruce/microservices-in-action/tree/master/chapter-7/feature/statsd
Already tried playing around with COPY and CMD command where I think might be the problem, but without success.
Here is the Dockerfile:
FROM alpine:3.6
MAINTAINER simplebank <engineering@simplebenak.book>
ARG port="8125"
ARG home="/root/"
ARG app_root="/var/code/simplebank/"
ARG app_name="statsd-agent"
ENV TERM xterm
ENV LANG=en_GB.UTF-8
ENV HOME $home
ENV REFRESHED_AT 2016-11-25
COPY . $app_root$app_name
RUN apk update && apk --update add \
ruby \
ruby-irb \
ruby-json \
ruby-rake \
ruby-bigdecimal \
ruby-io-console \
libstdc++ \
tzdata \
ca-certificates \
bash
RUN gem install bundler --no-ri --no-rdoc \
&& cd $app_root$app_name ; bundle install \
&& rm -rf /var/cache/apk/*
RUN chown -R nobody:nogroup $app_root$app_name
RUN chmod +x $app_root$app_name/statsd-agent.rb
USER nobody
EXPOSE $port/udp
WORKDIR $app_root$app_name
CMD ./$app_root$app_name/statsd-agent.rb
The Gemfile:
source "https://www.rubygems.org"
gem "term-ansicolor"
The statsd-agent.rb script
#!/usr/bin/env ruby
#
# This script is found in this post by Lee Hambley
# http://lee.hambley.name/2013/01/26/dirt-simple-statsd-server-for-local-development.html
#
require 'socket'
require 'term/ansicolor'
include Term::ANSIColor
$stdout.sync = true
c = Term::ANSIColor
s = UDPSocket.new
s.bind("0.0.0.0", 8125)
while blob = s.recvfrom(1024)
metric, value = blob.first.split(':')
puts "StatsD Metric: #{c.blue(metric)} #{c.green(value)}"
end
From the folder with dockerfile I build Image:
docker build -t statsd_service .
And run it:
docker run -dp 8125:8125 statsd_service
Now the container wont start and in Logs I see this:
': No such file or directory
Can you help me out please? Thx