Crystal: Docker images since 0.28.0 does not write to STDOUT

Created on 9 Jun 2019  路  6Comments  路  Source: crystal-lang/crystal

Hi. I have this issue, since crystal 0.28.0 container image I can't get any STDOUT to work properly. In image 0.27.2 it works fine. But on 0.28.0 and now 0.29.0 it doesn't work.

I'm using:

  • Docker (18.09.2) (Docker desktop community 2.0.0.3 (31259))
  • MacOs Mojave 10.14.5.
help-wanted to-research needs-more-info

Most helpful comment

Might be related to #7470.

All 6 comments

Might be related to #7470.

Try either to:

  • Set STDOUT.sync = true
  • Or use STDOUT.puts, which flush after printing.
  • Or use STDOUT.flush after STDOUT <<

Hello, using STDOUT.sync = true worked fine thanks. I'm not sure if we should start having differences when running on a machine or on a container.

It would be good if somebody could provide an isolated example showcasing the issue. Otherwise I would vote to close this since I think we have related issues with better descriptions :)

I haven't yet been able to exactly isolate the issue, but I've been trying to pinpoint.

FROM crystallang/crystal:0.30.0
ADD . /src
WORKDIR /src
RUN crystal build --release -s src/some_code.cr
ENTRYPOINT /src/some_code

Having a simple puts "some text here" in some_code.cr will work.

If I now make it a simple website using kemal and it's builtin logging, no output at all:

require "kemal"

get "/" do
  "Hello World!"
end

puts "Some Text"

Kemal.run

If I then add the STDOUT.sync = true as suggested above it'll output like it should:

require "kemal"

STDOUT.sync = true

get "/" do
  "Hello World!"
end

puts "Some Text"

Kemal.run

(For my own project having a custom logger, that initialized a ::Logger.new STDOUT somehow also worked, but I haven't been able to reproduce it with this "example")

I know this technically isn't really an isolated example, but maybe this will help.

I think we can close this, since last versions are working fine.

Was this page helpful?
0 / 5 - 0 ratings