nxweb Docker Image

13.11.2014

Docker is an application runtime and packaging tool that allows shipping applications with all required dependencies in a portable way. Dockerized nxweb image can be downloaded and put into production within minutes. Here is step by step guide on how to do this.

Install Docker

Docker installation options are detailed on the official site here.

In case you are on Ubuntu it is as simple as this:

curl -sSL https://get.docker.com/ubuntu/ | sudo sh

Note: I had to additionally apt-get install apparmor (docker service failed to start otherwise).

Run nxweb

sudo docker run --name="nxweb" --rm -it --net="host" nexoft/nxweb-build nxweb -H :8080

The first time you execute this Docker shall download latest nxweb image, which might take some time. Next time you run this nxweb shall start immediately.

Now you can check http://localhost:8080/ to explore nxweb sample configuration.

By default nxweb will serve content from inside downloaded container. But you can easily override it:

sudo docker run --name="nxweb" --rm -it --net="host" -v `pwd`:/srv nexoft/nxweb-build nxweb -H :8080

-v `pwd`:/srv option shall map your current working directory as nxweb's workdir. nxweb will look for nxweb_config.json file in it, or just serve static content in case there is no such file.

Compiling custom C modules

Let's say you have sample files from this tutorial in your current working directory. Running the following command shall put you inside nxweb container:

sudo docker run --name="nxweb" --rm -it --net="host" -v `pwd`:/srv nexoft/nxweb-build bash

Here you can run the following command to compile sample module:

nxwebc sample_handler.c -o sample_handler.so

Type exit or Ctrl+D to exit from nxweb container. Now run nxweb:

sudo docker run --name="nxweb" --rm -it --net="host" -v `pwd`:/srv nexoft/nxweb-build nxweb -H :8080

Check http://localhost:8080/sample to see the result.

Cleanup

You can completely remove downloaded nxweb image from your PC by executing:

sudo docker rmi nexoft/nxweb-build

For further instructions on how to use Docker please read the official guide.

Comments