Skip to content

This docker utility container will help us execute npm commands without installing node in our machine. I've used node 20.10-alpine version in this project.

License

Notifications You must be signed in to change notification settings

actionanand/node-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Utility Containers & Executing Commands - (Section 5)

This docker utility container will help us execute npm commands without installing node in our machine. I've used node 20.10-alpine version in this project.

How to run node in interactive mode as shell in our machine

docker run -it --rm --name node-util node:20.10-alpine

image

How to run node in interactive mode without any Dockerfile in terminal to use npm commands

docker run -it -d --rm --name node-util node:20.10-alpine
  • Executing npm command (say npm init)
docker exec -it node-util npm init

The docker exec command helps us to execute(run) a new command inside the running container.

image

Set-up using Dockerfile

  1. Build the image
docker build . -t actionanand/node-util
  1. You can run any command begining with npm (leave npm and add remaining at the end of following command)
docker run -it --rm --name node-util -v "D:\AR_extra\rnd\docker\node-util:/app" actionanand/node-util

For wsl2, mac and linux

docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util

To run npm init command

docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util init

To run npm install express

docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util install express

image

Set-up using docker-compose

  • docker-compose run is used to run single service from multiple services present indide docker-compose.yaml

Usage

docker-compose run --rm <service_name>

Consider npm-util is the registered service name in docker-compose.yaml and If you want to execute npm init, the following will be the command to be executed!

docker-compose run --rm npm-util init

So if npm is the registered service name,

docker-compose run --rm npm init

image

Docker Image's public URL

Associated repos:

  1. Docker Basics
  2. Managing Data and working with volumes
  3. Docker Communication
  4. Docker Multi-container with docker-compose
  5. Docker Utility Containers & Executing Commands
  6. Laravel with Docker
  7. Angular with Docker

About

This docker utility container will help us execute npm commands without installing node in our machine. I've used node 20.10-alpine version in this project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published