Node.js Web Server deployed within Docker
Updated by Linode
Use the Docker-maintained install script for Debian or Ubuntu. For other operating systems, see the Docker Installation guides.
curl -sSL https://get.docker.com/ | sh
The current version of the Docker script checks for AUFS support and displays the warning below if support is not found:
1 2 3 4
Warning: current kernel is not supported by the linux-image-extra-virtual package. We have no AUFS support. Consider installing the packages linux-image-virtual kernel and linux-image-extra-virtual for AUFS support. + sleep 10
This message can be safely ignored, as the script will continue the installation using DeviceMapper. If you require AUFS support, you will need to configure a distribution supplied or custom compiled kernel.
If necessary, add the non-root user to the “docker” group:
sudo usermod -aG docker example_user
Download the Docker Node.js Server Image
The Docker Hub user page for Linode can be accessed here. Select the server-node-js image for configuration information.
Docker images made for one operating system can be used on servers running a different OS. The server-node-js Ubuntu 14.04 image was tested on Debian 7, Ubuntu 14.04, Centos 7 and Fedora 21. After Docker installation on Centos and Fedora, run the
sudo service docker startcommand.
Search for linode images:
sudo docker search linode
Download the linode/server-node-js image:
sudo docker pull linode/server-node-js
Run the Docker Container, Node.js, and the Web Server
Note that when an image downloads, no image containers run.
Run, create or activate a new container. Forward the Linode’s port 80 to port 3000 of the container:
sudo docker run -p 80:3000 -t -i linode/server-node-js /bin/bash
This command also changes the terminal prompt to the root user within the new container.
From the container’s command prompt, change to the home directory, list the present files, and look at the server configuration:
1 2 3
cd ls cat server.js
Using the Node Version Manager, activate Node.js:
nvm use 0.10
Using the forever module, start the web server:
forever start server.js
To exit the container while leaving it running, press
ctrl + pand then
ctrl + q.
Test the server at
220.127.116.11with your Linode’s IP address. A page with “Test File” should appear.
The Docker Hub image page has information explaining what the Docker image contains.
For More Information
This guide is published under a CC BY-ND 4.0 license.