I wrote a script to build and run a docker container:
docker build --rm -t 'mine' . && docker run -p 3000:3000 -it 'mine'
If I run it two times in a row, the previous one is already running so it doesn't start. To fix this, I wrote a line to kill all docker containers:
docker kill $(docker ps -q) || true
docker build --rm -t 'mine' . && docker run -p 3000:3000 -it 'mine'
This works, but now I have multiple projects on my machine that use docker, and this kills all of them, which isn't what I want. I only want it to kill the docker container in this project.
How can I modify this script so it only kills the docker container(s) that are started in the second line?