Im running the following command in my GitLab CI job:
ssh ${REMOTE_HOST} "docker restart $(docker ps --format '{{.Names}}' | grep '^backend')"
The problem is that it returns me the following error:
/usr/bin/bash: line 156: docker: command not found
"docker restart" requires at least 1 argument.
I know that docker
does exist and works on the remote host, because I can log in to the host's shell and execute docker commands myself.
Based on my understanding the error seems two be two-fold - it tells me that "docker command is not found" and then tells me that "docker restart needs at least 1 argument".
So, I assume that the docker
executable is not found for the nested command, which returns the "docker: command not found" error, and since that returns no names of containers, then docker restart
fails as well.
I also tried replacing docker
with /usr/bin/docker
inside the nested command, but to no avail.
I know the ssh tunnel works correctly because just before that command, I execute the following two commands, which work fine:
ssh ${REMOTE_HOST} "docker pull my_registry/backend:${VERSION} "
ssh ${REMOTE_HOST} "docker-compose -f docker-compose.yml up --detach --remove-orphans"
So, I really believe the issue is that the docker
executable isn't found for the inner command.