Node.js Container


Recommended Posts

What I am trying to do is run a simple node.js app in a container, instead of the Ubuntu VM it is in now. I am a docker novice, but have been using it for a few years - mostly pre-made containers, but on Ubuntu I've made a few of my own that work as expected. I've never used a custom container in unraid, though, and the differences are tripping me up.

 

In the end, what I'm trying to do is exactly what is described on the official node.js docker page:

Quote

 

Run a single Node.js script

 

For many simple, single file projects, you may find it inconvenient to write a complete Dockerfile. In such cases, you can run a Node.js script by using the Node.js Docker image directly:

$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app node:8 node your-daemon-or-script.js

 

Is there a relatively straight forward way to do this in Unraid? I see how I can import the node container from docker hub, but past that I'm struggling.

 

Thanks in advance for any help or advice.

Edited by JasonJoel
Link to comment
37 minutes ago, JasonJoel said:

and the differences are tripping me up.

Just an FYI, but there are zero differences.  A container is a container is a container.  Thats the whole point of them.  Self-contained applications that can be run on any platform without modifications

Link to comment

Fair enough - poor wording choice on my part. How to do the container definition via the GUI was tripping me up.

 

I did get it to work, though, so thought I would come back and at least list how I did it (even though it was simple for anyone that understands docker better than I do :) ):

 

1. Imported node container from docker hub via CA

2. Set network to the interface I needed (br3 in my case)

3. Set static IP address

4. Added a path setting for the /user/src/app container location to /mnt/usr/appdata/<container name>

5. Switched to Advanced View

6. Added "-w /usr/src/app" in "Extra Parameters:"

7. Added "server.js" in "Post Arguments:", with server.js being the name of my node.js app.

8. Hit Apply and ran the container.

 

  • Thanks 2
Link to comment
  • 2 months later...
On 6/22/2019 at 9:45 AM, JasonJoel said:

6. Added "-w /usr/src/app" in "Extra Parameters:"

7. Added "server.js" in "Post Arguments:", with server.js being the name of my node.js app.

 

 

Thank you for posting these steps. I had the worst time figuring this out for whatever reason.  How did you figure out the extra parameter and post argument steps?

  • Upvote 1
Link to comment
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.