1

I have a nodejs application inside a docker containter, and I'm trying to run another docker image from the container.

I connected the docker socket to the container, ran the machine, and I went into the containter.

docker run -it  -v /var/run/docker.sock:/var/run/docker.sock  -w /root node bash

When I write in the terminal docker I get an error: bash: docker: command not found.

It happens precisely in the specific image of NodeJS, if for example I run such a test

docker run -v /var/run/docker.sock:/var/run/docker.sock \
            -ti docker

It works great.

Why can't I run docker in the node image?

5
  • can you please specify what image are you using Commented Sep 20, 2022 at 19:10
  • The question is not quite clear, further clarification needed. You have build a docker image with your nodejs app, you start an 'instance' of docker image and it became, so to say, docker container. You may start another docker container with different port mapping from you docker image, this works. But what is the reason of trying to run a docker inside a container you started? Commented Sep 20, 2022 at 19:13
  • Do you want a nested container? Or to started another docker container from docker image is your intention? Commented Sep 20, 2022 at 19:15
  • @VaheYavrumian I specified the image: node Commented Sep 20, 2022 at 19:47
  • @m19v The code I gave is just an example, I have a container with an active Node app, I don't need a child image but a sister images Commented Sep 20, 2022 at 19:49

1 Answer 1

1

This not work because to mount sockets nodejs container must include a docker instance inside it. Just try another general image other than docker. It also will not work. Search for nodejs images it self include docker. Use that then it will work.

If such image not exist you have to create new image from both docker and nodejs images and add command to start it.

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.