Step 6: Run the application

Packaging System Demo

Now that the build is complete, let's test it out by running the package. Two common ways of running a package include:

  • Start services directly from the Studio* using the Chef Habitat Supervisor, or
  • Export the .hart to a Docker image and use docker run.

We've mentioned the benefits of Chef Habitat's export capabilities, so let's see how how that works now. With a single command, you will have exported the .hart file as a Docker image.

[1][default:/src:0]# hab pkg export docker ./results/<path to .hart>

After the export finishes, exit the studio (or open a new terminal window in the same location) and run the Docker container.

[1][default:/src:0]# exit
$ docker run --env HAB_LICENSE="accept-no-persist" -it -p 8000:8000 yourorigin/sample-node-app

*On some operating systems, the Chef Habitat Studio runs as Docker container, so if you wanted to view a sample application running within a Studio, you'd need to expose a port using one of Chef Habitat's environment variables.

Preview the application in your browser

Finally, go to http://localhost:8000 in your browser to see the sample application UI (screenshot below).

Screenshot of sample node app running in web browser

That's a wrap!

By building your application with Chef Habitat, you are now able to take advantage of all the capabilities baked into your build artifact. For example, in the Build System demo you'll learn how to automate the build process and (optionally) publish your artifacts to various container registries, all using Chef Habitat Builder.