UBUNTU container to run a Node-JS based app
958
This image provides an UBUNTU container to run a Node-JS based app.
You are able to choose wether the app is running as user or as root.
Assuming that your user has the docker privileges, here is an example for creating and running the container:
docker run -i -t \
-p 3000:3000 \
-e ENV_VAR="variable to the app" \
--name=MyNodeContainer mbinunn/ubuntu_node_app_executor
If you want to run the app as root, use:
docker run -i -t \
-p 3000:3000 \
-e RUN_AS_ROOT=1 \
-e ENV_VAR="variable to the app" \
--name=MyNodeContainer mbinunn/ubuntu_node_app_executor
If you want to load your app folder from the host, use:
docker run -i -t \
-p 3000:3000 \
-v /path/to/app/on/host:/home/administrator/app \
-e ENV_VAR="variable to the app" \
--name=MyNodeContainer mbinunn/ubuntu_node_app_executor
NOTES:
-You must implement the npm start option in your app's package.json file, otherwise the app won't run!
-The port 3000 on the usage example is for the example app that will run by default. Change the port to the needs of your own app.
-In the usage example I'm running the container in the interactive mode with the -i switch, so that we're able to see the app's output. You can use the -d switch to run in detached mode instead.
-To have your app running continously in a production server, use --restart=always so that your app will be automatically running after a host server restart.
-The ENV_VAR is only a variable for the example app. You can pass any "-e" variable that you want, and then get it in your app by calling
const YOUR_VAR = process.env.YOUR_VARIABLE || '';
(same as you would getting a regular bash exported variable).
RUN_AS_ROOT = Pass this variable only if you want to run the app as the container's root, otherwise do not pass it
SUDO_PASSWD = Initializes the sudo user's password
ROOT_PASSWD = Initializes the root password of UBUNTU
After making changes, installing software or changing startup.sh, save your own image by using the following command:
docker commit MyNodeContainer my_own_node_image:v1
See my source code on https://github.com/mbinnun/Dockers/tree/main/ubuntu-node-app-executor
Content type
Image
Digest
Size
182.9 MB
Last updated
over 5 years ago
docker pull mbinunn/ubuntu_node_app_executor