Home > Software engineering >  Run docker command into node container
Run docker command into node container

Time:09-21

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?

CodePudding user response:

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.

  • Related