As I mentioned, I starting to learn and use Docker. Therefor I followed a nice YouTube tutorial which really gave me a kickstart. However, it seems that the way to terminate a docker container has either changed or was described wrong in this video. So I learned myself by checking what the docker function in PowerShell can do.
I tried terminating Docker Containers by simply pressing
CTRL-C. I thought I’m done with that but no, I was not. That simply terminates the docker command process but not the container. I realized that when I wanted to start the same container right after I thought I terminated it. But an error (“docker bind failed port is already allocated”) popped up. So I checked Kitematic to find that the container still showed up running. (Also, going to
localhost:80 still returned the webpage after “terminating” the container which seemed odd…)
So, simply CTRL-C did not do the trick. But thankfully there is
docker stop and
docker kill. But those commands need the (thankfully) human readable docker names. Unfortunately, docker run does not show you the name of the docker container it just started. However,
docker ps does.
Here’s my current workflow:
docker run -p 80:80 -v host:container buildname
- do whatever I do (coding, testing,…)
docker psand find out the name of my container
docker stop containername
Is it the easiest? I don’t know. Is it the best? I don’t know. But maybe you know a simpler, better, smarter solution! I’d be happy to hear about it in the comments!