Home > Mobile >  Kill a docker container using awk command in gitlab-ci.yml
Kill a docker container using awk command in gitlab-ci.yml

Time:09-23

I would like to use awk in gitlab-ci.yml to kill a docker container. However, awk does not work as expected. For example, I want to kill a docker container called ADockerContainer using awk. Therefore I use the following command:

docker kill $(docker ps | grep ADockerContainer | awk '{print $1}')

After the execution of the command, I get:

"docker kill" requires at least 1 argument.

Does anyone know how to fix this?

CodePudding user response:

docker kill (and other commands) will take the container name directly, so you don't need any sort of command substitution here. It's enough to run

docker kill AContainerName
  • Related