ABE
ABE

Reputation: 706

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?

Upvotes: 1

Views: 515

Answers (1)

YJR
YJR

Reputation: 1202

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.

Upvotes: 1

Related Questions