I am running several docker containers running on my server, and need to exec a git pull for a repository that is on all of them.
I have tried using this:
Using Docker exec you can run the command on the container one at a time, but from your Question you want to run the command on all running container, here you go.
for containerId in $(docker ps -q)
do
docker exec -it $containerId bash -c 'cd /var/www/html && git pull'
done
I assume git is already installed in all running container and all base on bash
Or more compact form can be
for i in `docker ps -q`; do docker exec -it $i bash -c 'cd /var/www/html && git pull'; done