0

I am trying to run golang code binary inside my docker container but I am unable to see the process inside the container or the log file generated using the code inside the binary. Please suggest if I am missing anything here.

FROM golang:1.19
WORKDIR /app
COPY  main /app
CMD ["./main"]. # Tried ["/bin/bash", "-c", "./main"] or ./main

I have already tried using -d with running container and checked the logs.

Deepak Mourya
  • 340
  • 2
  • 10
  • Maybe it ran and exited? – Burak Serdar Dec 04 '22 at 18:51
  • Hmm if it does, a log file would be generated because if I run the same command inside the container it will create my log file. So confused about what is missing from my end. – Deepak Mourya Dec 04 '22 at 18:55
  • 3
    If your program writes to a log file inside docker, that log file is gone when the container terminates. – Stephen Newell Dec 04 '22 at 19:18
  • @StephenNewell Agree thanks for raising this point, my main objective is to set this script running in the background, Can you suggest what should be the way forward.? – Deepak Mourya Dec 04 '22 at 19:24
  • 1
    Your container almost certainly ran to completion. If you need it to run in the background, then you've already discovered the `-d` flag. If you mean something else, [edit] your question with those details. – Stephen Newell Dec 04 '22 at 20:10
  • Have you tried to get into your container using `sh` (or `bash`), then run `./main`, so that you can see error messages ? – Philippe Dec 04 '22 at 20:30
  • @Philippe Yes I did, I am able to see my code running using ./main – Deepak Mourya Dec 05 '22 at 05:45

0 Answers0