Saeed Afshari
Saeed Afshari

Reputation: 949

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

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?

Upvotes: 0

Views: 370

Answers (1)

David Maze
David Maze

Reputation: 159732

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

Upvotes: 1

Related Questions