https://github.com/actionanand/node-util
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.
https://github.com/actionanand/node-util
docker docker-compose node-alpine node20
Last synced: 10 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/actionanand/node-util
- Owner: actionanand
- License: mit
- Created: 2023-12-28T08:19:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-31T17:42:36.000Z (about 2 years ago)
- Last Synced: 2025-02-07T18:17:30.263Z (12 months ago)
- Topics: docker, docker-compose, node-alpine, node20
- Language: Dockerfile
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```shell
docker run -it --rm --name node-util node:20.10-alpine
```

## How to run node in interactive mode without any Dockerfile in terminal to use npm commands
```bash
docker run -it -d --rm --name node-util node:20.10-alpine
```
- Executing npm command (say `npm init`)
```bash
docker exec -it node-util npm init
```
The docker `exec` command helps us to execute(run) a new command inside the running container.

## Set-up using Dockerfile
1. Build the image
```shell
docker build . -t actionanand/node-util
```
2. You can run any command begining with `npm` (leave `npm` and add remaining at the end of following command)
```bash
docker run -it --rm --name node-util -v "D:\AR_extra\rnd\docker\node-util:/app" actionanand/node-util
```
For wsl2, mac and linux
```bash
docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util
```
To run `npm init` command
```bash
docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util init
```
To run `npm install express`
```shell
docker run -it --rm --name node-util -v $(pwd):/app actionanand/node-util install express
```

## Set-up using docker-compose
* `docker-compose run` is used to run **single service** from multiple services present indide `docker-compose.yaml`
Usage
```bash
docker-compose run --rm
```
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!
```bash
docker-compose run --rm npm-util init
```
So if `npm` is the registered service name,
```bash
docker-compose run --rm npm init
```

### Docker Image's public URL
* [actionanand/node-util](https://hub.docker.com/r/actionanand/node-util)

## Associated repos:
1. [Docker Basics](https://github.com/actionanand/docker_playground)
2. [Managing Data and working with volumes](https://github.com/actionanand/docker_data_volume)
3. [Docker Communication](https://github.com/actionanand/docker_communication)
4. [Docker Multi-container with docker-compose](https://github.com/actionanand/docker_multi-container)
5. [Docker Utility Containers & Executing Commands](https://github.com/actionanand/node-util)
6. [Laravel with Docker](https://github.com/actionanand/laravel_with_docker)
7. [Angular with Docker](https://github.com/actionanand/angular_with_docker)