title: golang program running fine outside of docker, but exiting with 0 when dockerized
body: <p>I have the following docker-compose.yml file:</p>
  
  <pre><code>version: "3.3"
  
  services:
    api:
      build: ./api
      expose:
        - '8080'
      container_name: 'api'
      ports:
        - "8080:8080"
      depends_on:
        - db
      stdin_open: true
      tty: true    
      networks:
        - api-net
  
    db:
      build: ./db
      expose:
        - '27017'
      container_name: 'mongo'
      ports:
        - "27017:27017"
      networks:
        - api-net
  
  networks:
    api-net:
      driver: bridge
  </code></pre>
  
  <p>and the Dockerfile for the api container is as follows:</p>
  
  <pre><code>FROM iron/go:dev
  RUN mkdir /app
  COPY src/main/main.go /app/
  ENV SRC_DIR=/app
  ADD . $SRC_DIR
  RUN go get goji.io
  RUN go get gopkg.in/mgo.v2
  # RUN cd $SRC_DIR; go build -o main
  CMD ["go", "run", "/app/main.go"]
  </code></pre>
  
  <p>If I run the code for main.go outside of a container it runs as expected, however if I try to run the container as part of docker-compose I get an exit 0. I have seen other threads on stackoverflow that have suggested using stdin_open and tty, but these have not helped. I have also tried creating an .env file in the same directory I issue docker-compose up from with <code>COMPOSE_HTTP_TIMEOUT=8000</code> in it and this has not worked either. I am looking for helped and suggestions as to what I need to do in order for my api container to stay up.</p>
  
  <p>I know that <code>--verbose</code> can be issued with docker-compose, however I'm not sure what I should be looking for in the output that this produces.</p>