Send commands to container

Hi all,

I have my docker container (centos), inside my container, I execute this command
./script.sh --cmd “command” host, how can i do the same from the outside the container.?

Thanks.

docker exec containerid 'command string’
and make sure you are in the right location for the ./
so

docker exec containerid './script.sh --cmd “command” host'

on question my path for the script is at
/home/deb/net/script.sh ,
to execute the script with the full path I would have to use

docker exec containerid ‘/home/deb/net/./script.sh --cmd “command” host’ ??

thanks.

that path must be INSIDE the container so you would copy script.sh into the container someplace

then execute it from that location…

/home/deb sounds like a host folder

that path is inside the container, but my question will be if that the write way to execute the script?

there is no other built in mechanism to inject execution in an already running container.

you can develop other mechanisms…

on one of my containers, i setup a web server, with a simple form,
the user selects from a dropdown of functions, that then hits submit…
this invokes a php script, which takes the input and executes a matching command from a predefined table

Hello ,
I moved my script to the “/” and I get this error
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:2
47: starting container process caused no such file or directory"

use

docker attach container_id 

to get a commandline in the container,
and debug the problem… name wrong, file not present, command to be issued not in root or path…

I connec to the container and i execute the same command and I dont get any issue the problem is when I run this outside the container.

show exactly what u typed at console and command executed from outside…

something is different