title: How to wait for a command to finish executing inside a container
body: <p>Using the following dockerfile:</p>
  
  <pre><code>FROM golang:1.9 AS build-go
  RUN go get github.com/grafana/grafana; exit 0
  WORKDIR $GOPATH/src/github.com/grafana/grafana
  RUN go run build.go setup
  RUN go run build.go build
  
  FROM node:8 AS build-node
  COPY --from=build-go $HOME/go/src/github.com/grafana/grafana .
  RUN npm install -g yarn
  RUN yarn install --pure-lockfile
  CMD npm run watch
  EXPOSE 3000
  </code></pre>
  
  <p>I create and image which is then used to start a container by the bash file:</p>
  
  <pre><code>docker run -d -P --name=grafanabuildfromsrc myimg
  docker exec grafanabuildfromsrc ./bin/linux-amd64/grafana-server
  </code></pre>
  
  <p><code>./bin/linux-amd64/grafana-server</code> requires <code>npm run build</code> to finish building all the files once. The current script would execute it before the build is finished.</p>
  
  <p>What I am wanting is that before the second command in the bash file is executed it should wait for the command inside the container to finish first. Is this possible?</p>
  
  <p><em>A maybe important note:</em> the <code>grafana-server</code> says <code>"Failed to detect generated javascript files in public/build</code> when <code>npm run watch</code> does not finish.</p>
  
  <p>How do I achieve this?</p>