简体   繁体   中英

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 .

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM