A crude NodeJS demo app attaching the local Docker socket that exposes the Docker CLI via REST.
INTENDED FOR LOCAL DEMO PURPOSES ONLY!
This exposes the Docker CLI via REST. You DO NOT want this running in production. Or anywhere really for that matter.
^^^ just to be clear.
Ok, so you want to run this locally - just to test it out...
To run locally, simply clone this repo and compose up...
git clone https://github.com/rjchicago/docker-node-demo.git
cd docker-node-demo
docker-compose up --build
open http://localhost:3000/ps
You can format many docker command results as json. For example
curl -H 'accept: application/json' http://localhost:3000/container/ls | jq
or via query param...
http://localhost:3000/container/ls?format=application/json
You may provide segment templates to be replaced by query params.
Tip: you may pass multiple query params of the same name. (i.e. to support multiple ports or volumes)
Example:
http://localhost:3000/run/--name/hello_nginx/-d/--rm/port/nginx?port=-p%208080:80&port=-p%208888:80
Then check the process is running...
Then see it working...
Welcome to nginx!
Finally, stop the nginx container