How to run command from inside of docker

Hey, everybody!

Is there an ability to run a non docker command from inside the container?

For example i have a php container. And inside a php script i want to execute a command via exec() php function that would work outside the container.

For example inside php container i want to run command “service cron restart” and this command should work in linux OS in which docker is installed (not inside the container).

So basicly you asking if there is known exploit to break out of the container…

You might be better of to use a unix domain socket created outside your container, mount it in your container, make your containerized php process write the commands into the socket, then implement a client (needs to run directly on the host) that reads data from the sockets and does the command execution.

yes, i’ve tried to mount docker.sock into container, but i do not understand how to work with it, so that it would run a commsn outside the container… (((

Is there any example or manual how to work with it? Better example of course ))))

Not from the top of my head. Google is your friend ^^

Also: do not try to abuse the docker.sock, you will need to create your own socket.