Docker Community Forums

Share and learn in the Docker community.

How to execute shall script or other script or command in running container

docker

(Keyurvr) #1

Hello

I have multiple containers in my private network.

I want to execute command like in running container without enter in it.

Like i want to some bash file in my main host and i want to execute in my running container same i also want to execute command in my running container.

Please suggest me


(Think) #2

(Keyurvr) #3

Hey Thanks !!

It’s working but when I execute from jenkins it gives below error.

[SSH] executing…
the input device is not a TTY

[SSH] completed
[SSH] exit-status: 1

Build step ‘Execute shell script on remote host using ssh’ marked build as failure
Finished: FAILURE


(Think) #4

Jenkins does not execute jobs in a tty. So when you exec into your container, do not do “-t”

For jenkins and docker, this is probably the way to go:


(Keyurvr) #5

Yes I have tried without -t and it’s working.
Thanks for the support.


(Keyurvr) #6

You can also try with below mentioned command

docker exec -i container-id sh -c ‘cd /var/www/html/wordpress && git pull’

Above command execute pull in to container.