Reputation: 5705
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
> docker stop 210ebea2ef5f
210ebea2ef5f
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
huh?
> docker kill 210ebea2ef5f
Error response from daemon: Cannot kill container: 210ebea2ef5f: Container 210ebea2ef5f6f25265a3da88954fe111fabba99602ef628e0ee88630e26fd5d is not running
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
has anybody some enlightenment on what's going on here? I've started noticing this once I've enabled restart policies on my containers. This is running in docker for windows (18.09.3). The restart policy is set using docker compose as follows:
version: '3'
services:
foo:
build: .
image: localhost.localdomain/${repository_name}
container_name: ${container_name}
restart: unless-stopped:0
Are restart policies just buggy in docker for windows?
btw. a docker rm 210ebea2ef5f
did finally remove the container from my docker ps list, but that's not the behavior I'd expect.
Upvotes: 3
Views: 4295
Reputation: 265060
This looks like a bug with docker ps
that is being fixed in 18.09.5. If you inspect the container with:
docker inspect 210ebea2ef5f --format '{{ json .State }}'
the status should show as exited.
The reason I suspect you're seeing this bug with docker ps
is because the status shows 9 minutes ago where a normal crash loop happens in seconds. You can try the rc1 for 18.09.5 that was just pushed (this requires that you are pulling updates from the testing release), or wait for the final 18.09.5 to be released and update to that. It appears to only be an issue with the ps output, and have no effect on the behavior of the containers themselves.
Upvotes: 1
Reputation: 312650
Your restart policy is doing exactly what you've asked it to do.
If you look at the STATUS
column in the output of docker ps
, you see:
Restarting (1) 9 minutes ago
This typically means that the container is not running successfully: it starts, then exits immediately, and is then immediately restarted by Docker. This means that there are good odds that when you run docker kill
, the container is in fact not running.
You could run docker stop <id>
to stop the container and prevent it from restarting.
You would need to investigate your logs and your Dockerfile
to determine why the container is exiting in the first place.
Upvotes: 0