Node + Nginx locally
cloud-node-container (image: cnoc) is the same Node + Nginx image we use for hosted Node sites. It’s based on AlmaLinux 9, ships with Node 18, 20, and 22 side-by-side (default 20), uses PM2 as the process manager, and fronts your app with Nginx (SSL + HTTP→HTTPS redirect).
What’s included
Section titled “What’s included”- Multiple Node versions — 18, 20, 22, switchable via
NODEVERenv var or the-aflag. - PM2 for production-grade process management — automatic restart, log rotation.
- Nginx reverse proxy with SSL and HTTP→HTTPS redirect.
- Memcached for sessions, automatic backups, log rotation.
/pinghealth endpoint baked into the proxy config.
Image tags
Section titled “Image tags”Pull from repo.anhonesthost.net/cloud-hosting-platform/cnoc:<tag>. The most useful tags:
cnoc:latest— the default (Node 20).- Version-pinned tags follow the same pattern (
cnoc:node18,cnoc:node20,cnoc:node22).
Check the repo for the current tag list.
Quick start with local-dev.sh
Section titled “Quick start with local-dev.sh”The repo ships a local-dev.sh script that handles the Docker run, creates the bind-mount layout, generates helper scripts, and scaffolds a sample Express app if none exists.
-
Clone the repo and
cdin:Terminal window git clone https://repo.anhonesthost.net/cloud-hosting-platform/cloud-node-container.gitcd cloud-node-container -
Start a local instance:
Terminal window ./local-dev.sh -n local-dev -
The script will:
- Create user + log directories (
nginx/,nodejs/). - Scaffold a default Express app under
user/app/if you haven’t dropped your own in yet. - Start the container with the right env vars.
- Generate helper scripts (
instance_start,instance_stop,instance_logs,instance_shell).
- Create user + log directories (
-
Open
http://localhost/in a browser — the sample Express app’s response page should be there. Or hithttp://localhost/pingto confirm the health endpoint.
| Flag | Purpose | Default |
|---|---|---|
-n | Container name (required) | — |
-p | HTTP port | 80 |
-s | HTTPS port | 443 |
-r | Root path for files | current directory |
-a | Node version (18, 20, 22) | 20 |
-v | Verbose mode | off |
-h | Show help | — |
Example — run a Node 22 instance on port 3000:
./local-dev.sh -n my-node22-app -a 22 -p 3000 -s 3443Manual Docker usage
Section titled “Manual Docker usage”mkdir -p local-development/domain.tldcd local-development/domain.tldmkdir usermkdir -p user/{app,logs/{nginx,nodejs}}
docker run -d \ -p 80:80 -p 443:443 \ -e NODEVER=20 -e environment=DEV \ --mount type=bind,source="$(pwd)"/user,target=/home/$(whoami) \ -e uid=$(id -u) -e user=$(whoami) -e domain=localhost \ --name local-dev \ repo.anhonesthost.net/cloud-hosting-platform/cnoc:latestGet a shell inside the container
Section titled “Get a shell inside the container”docker exec -it local-dev /bin/bashUseful for running pm2 ls, pm2 logs, or npm commands against your bind-mounted app folder.
Where your code goes
Section titled “Where your code goes”Your Node application lives at user/app/ on your laptop. Inside the container that’s /home/<user>/app/. The container is configured to run your app from there via PM2.
Minimum required files in user/app/:
package.json— describes your app and dependencies; must define a start command ("start": "node server.js"inscripts).- A main JavaScript file — typically
server.jsorindex.js.
After dropping files in, restart the container so PM2 picks up the new app:
docker restart local-devYour app should bind to the port shown by the container’s env var (usually process.env.PORT). Nginx forwards traffic to that port internally and proxies SSL.
| Where | What |
|---|---|
user/logs/nginx/ | Nginx access + error logs |
user/logs/nodejs/ | PM2’s stdout/stderr capture from your Node app |
Tail them from your laptop:
tail -F user/logs/nodejs/*.logOr via the helper script:
./instance_logsStop / start / clean up
Section titled “Stop / start / clean up”./instance_stop # stop the container./instance_start # start it again./instance_logs # view container logs./instance_shell # exec into the containerTo wipe everything:
docker rm -f local-devrm -rf local-development/Source
Section titled “Source”cloud-node-container on Gitea — Dockerfile, Nginx + PM2 configs, entrypoint, and the local-dev.sh script.
Related
Section titled “Related”- PHP + Apache locally
- Create a site — the hosted side.
Still stuck?
Section titled “Still stuck?”Still stuck? Open a support ticket and our team will help.