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?
docker-composedocker kill container_name. In your case, it would bedocker kill minedocker kill mine, I saydocker kill container_namewhich I have to get fromdocker container ls. Therefore, I don't think this is the same question. I'm asking for a one-line script to do all these steps, not a manual series of steps.