How can i run docker command inside a docker container?

most important part change permission for /var/run/docker.sock
sudo chmod 666 /var/run/docker.sock
otherwise it give you permission error inside contiainer

This is not a good idea, as it opens up the docker.sock to everyone who is able to login into that machine.

Something like tecnativa/docker-socket-proxy might be a better option, as it exposes the docker.sock over the network and can be put in an isolated network with the api client container to make sure the socker-proxy is not accidentally exposed to other containers.

This approach even allows which sections of the api can be used.

Preformatted text[root@ip-172-31-56-74 ~]# docker container attach ce8886f749c9
/ # docker commit ce8886f749c9 myfirstcommit:v1
sh: docker: not found
/ # docker login
sh: docker: not found`

I am getting this docker not found message while trying to commit my new image. Any lead why I am getting this error ?