How can we run a command on anothe linked container from existing container

I have 2 containers up and running.

i am logged in into one container say container A, I want to execute command x in container B from container A.

To elaborate,

My application has php, mysql and other tools in another container. When user clicks specific link on my php app, a specific command should run on the 3rd container.

Is this possible? If yes, can this be eloberated?

Many Thanks in Advance

I have tried docker-in-docker command, this doesn’t seems stable and secure.

Expecting to run a command in another container which is linked to this and should be run through php if possible.

Source: StackOverflow