0

I' m trying to run npm install without installing npm:

sudo docker run -it -v $PWD/../src:/usr/src/app node:latest npm install 

However I don't know where the WORKDIR of node:latest is located. I want node_modules installed in the folder $PWD/../src. I also don't want to create a dockerfile just for that.

2
  • That requirement doesn't make sense, any more than trying to ask Stack Overflow questions without using a Web browser does. (You also can't really effectively use Docker for custom applications without writing Dockerfiles.) Install the tools you need to get your job done. Commented Feb 23, 2020 at 18:34
  • @DavidMaze I don't see why it isn't possible. Many applications are dockerized so the person doesn't need to install it. Why wouldn' t it work? I' m mapping my project to the inside of this docker container, and it has npm installed. When I run npm on it, I should get the node_modules installed in the mounted volume, and then when the app exists, I still get the volume in the machine. I just need to know which workdir node:latest uses Commented Feb 23, 2020 at 18:45

1 Answer 1

1

This is actually a valid use case for using Docker where you just want to have a quick temporary environment to execute your scripts.

In case you do not know the WORKDIR of any image, you can still overwrite it when creating the container as described here.

sudo docker run --rm -it \
  -w /any/directory \
  -v $PWD/../src:/any/directory \
  node:latest \
  npm install

NOTE I added the flag --rm so that the container will automatically be cleaned up once the npm install command finishes running.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.