Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run docker command into node container

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading