Docker Community Forums

Share and learn in the Docker community.

Send commands to container


(Tcpip) #1

Hi all,

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


(Sam) #2

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

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

(Tcpip) #3

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

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


(Sam) #4

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

then execute it from that location…

/home/deb sounds like a host folder

(Tcpip) #5

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

(Sam) #6

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

(Tcpip) #7

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"

(Sam) #8


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…

(Tcpip) #9

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.

(Sam) #10

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

something is different