Live Debugging with Docker
During the DockerCon 2016 keynote, I demonstrated a development workflow with Docker for Mac, going from a fresh laptop to a running app in no time. The especially cool part was when I live-debugged a Node.js app running inside a container from my IDE, despite having no Node.js runtime installed on my laptop. Here I’m going to show you how to do it yourself.
Here’s what you’ll need:
- Docker: I recommend Docker for Mac or Windows, which are in public beta.
- An IDE which supports Node.js remote debugging: I used Visual Studio Code.
- A Node.js application: I’ll create a simple one as part of this tutorial.
Example Application
Create a directory to work from:
$ mkdir node-example $ cd node-example
To get our app running, we’ll need 5 files:
- A JavaScript file to contain the actual app code
- A
package.jsonto define the npm dependencies - An HTML template
- A
Dockerfileto package the whole app in a container - A Compose file to set up a development environment. (The Compose file will also come in very handy if the app ever grows beyond a single container, but we won’t bother with that today.)
Create Continue reading
IoT make this environment a hacker’s Candy Land.
