0

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

Retko
  • 332
  • 1
  • 5
  • 14
  • 1
    Try to run `docker run -it --rm -p 8125:8125 statsd_service /bin/sh` and to debug the issue inside the container – Yuri G. Jul 10 '22 at 18:04

1 Answers1

0

Finally was able to make it run. I had to change line endings of the files to UNIX style (instead of Windows) - Did it via Sublime text - View -> Line Endings - UNIX ==> change line endings in sublime

Also this helped - Trying to run Docker resulted in exit code 127

Retko
  • 332
  • 1
  • 5
  • 14