I am running multiple docker containers on a remote server which are tagged by my username. The containers run some code with printed outputs. I want to do a string search for string "xyz" using grep on the output of all the containers that belong to me(filter by username). Below is my attempt doing this which doesn't seem to work:
docker ps -a -q --filter name=${USER} --format="{{.ID}}" | xargs -d ' ' docker logs | grep xyz BONUS: I want a python script that does the above for me on all the servers I am running my containers on, from my macbook, something like this:
os.system('ssh {}@{} \"docker ps -a -q --filter name={} --format={{{{.ID}}}} | xargs -d ' ' docker logs | grep xyz\"'.format(usern[server], server, usern[server])) Where "server" is the server name and "usern" is a dict storing my username for that server. My ssh keys are stored.
Obviously I am struggling to make this work too.
docker ps -a -q --filter name=${USER} --format="{{.ID}}"output? Then, what doesdocker ps -a -q --filter name=${USER} --format="{{.ID}}" | xargs -d ' ' docker logsoutput?