title: How-to run a node.js docker instance dropping into a shell that is auto-tailing logs
body: <p>SO...</p>
  
  <p>I am trying to create an elegant docker / node setup for my team on a greenfield prototype project. My team will need to have Node / NPM and Docker CLI installed beforehand, but afterwards I will be using NPM to manage everything and previously had...</p>
  
  <pre><code>"scripts": {
      "docker": "npm run docker-build &amp;&amp; npm run docker-start",
      "docker-build": "docker build -t docker_foo .",
      "docker-start": "docker run -it -p 8080:8080 --rm docker_foo",
      "start": "node server.js"
  }
  </code></pre>
  
  <p>...and the Dockerfile contains the CMD...</p>
  
  <pre><code># Other stuff...
  
  EXPOSE  8080
  
  CMD ["npm", "start"]
  </code></pre>
  
  <p>...that will eventually start the node server. This works really well for seeing logs and cleaning up containers, but I want to make it better. I would like to instead start the container in the background using the -d option and attach to the container instead with an initial command tailing the logs to simulate the same behavior except that when the user terminates the process, they are still in the container so they can evaluate the container's current state. This led me to have...</p>
  
  <pre><code>"scripts": {
      "docker": "npm run docker-build &amp;&amp; npm run docker-start &amp;&amp; npm run docker-attach",
      "docker-build": "docker build -t docker_foo .",
      "docker-start": "docker run -d -p 8080:8080 --name docker_foo docker_foo",
      "docker-attach": "docker exec -it docker_foo /bin/ash",
      "docker-clean": "npm run docker-clean-containers &amp;&amp; npm run docker-clean-images",
      "docker-clean-containers": "docker ps -a -q | xargs docker rm -f -v",
      "docker-clean-images": "docker images -f 'dangling=true' -q | xargs docker rmi",
      "start": "node server.js"
  }
  </code></pre>
  
  <p>...but I am having some trouble finding where the node server logs are stored either on the container or on my local host to enable this desired workflow. Is there some way to re-direct the STD out and err to a location inside the container for historical purposes and a way to expand my attach command above to initially be tailing those logs?</p>