Py-KMS-Organization/py-kms

Can’t keep in background on docker

QFJABC opened this issue · 18 comments

Hello,I recently found something strange. The docker container on my Debian server can't keep in the background.I must connect to my server with Putty and it will run. If I exit the terminal,it will stop working.

When I logon the server,and run "docker ps",as you can see,it returns me "up less than a second",which means it just working when I logon!
Uploading 208871931...

What command are you using to start the container?

What command are you using to start the container?

docker run -d --name py-kms --restart always -p 1688:1688 ghcr.io/py-kms-organization/py-kms
By the way fix up the picture

屏幕截图 2022-12-21 172835

Please make sure to pull the latest image once more - and send the output from docker image ls. Because I've started the container with the same command you used (without --name as I've run it before):

$ docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED       STATUS                 PORTS                                       NAMES
502d8f849bdc   ghcr.io/py-kms-organization/py-kms   "/usr/bin/python3 -u…"   5 hours ago   Up 5 hours (healthy)   0.0.0.0:1688->1688/tcp, :::1688->1688/tcp   hopeful_cohen

...and it is still running...

Ok,I will try that.

屏幕截图 2022-12-23 184942

It doesn't work....

I'm sorry, but you failed to pull the image correctly. This is my output:

$ docker pull ghcr.io/py-kms-organization/py-kms
Using default tag: latest
latest: Pulling from py-kms-organization/py-kms
9621f1afde84: Pull complete 
6831eb133204: Pull complete 
7dc84511a6a9: Pull complete 
c212f116beae: Pull complete 
6a2cecfb044b: Pull complete 
7f1cf1037d65: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:830c65dac504b2ebdff18e8126f3c66db06860f306a9703e15b598642b8d9de9
Status: Downloaded newer image for ghcr.io/py-kms-organization/py-kms:latest
ghcr.io/py-kms-organization/py-kms:latest
$ docker image ls
REPOSITORY                           TAG       IMAGE ID       CREATED       SIZE
ghcr.io/py-kms-organization/py-kms   latest    3ee7f5ad967e   13 days ago   103MB

As you can see, the latest image hash is 3ee7f5ad967e, while you are using 6b45015e0975. Try to use docker pull again.

Now I pull the image correctly, but the problem still have.

Okay. Then I should be able to reproduce this. Could you please destroy your existing container, recreate it using the run instruction and share the output of docker ps and docker inspect [CONTAINER_NAME]?

Hello, and here are the images.

docker ps result
docker inspect result-1
docker inspect result-2
docker inspect result-3
docker inspect result-4
docker inspect result-5
docker inspect result-6

@simonmicro how can a container get stuck in a startup loop when it's health-check is apparently passing?

In the docker ps output it looks as though the container is successfully daemonised but without a passing health check.

I see in the inspect it's not got a failure streak and also that it's returning zero so what is making docker think it's not started?

Edit:

Looking at the code, I can see we Netcat the KMS port in the container to check it's health. In the inspect output I can see it's returning zero but docker seems to think it's "starting".

@Matthew-Beckett My Windows won't active unless I start Putty for a while.....I don't think it started.

@Matthew-Beckett My Windows won't active unless I start Putty for a while.....I don't think it started.

Is your system dual-stack enabled? I don't expect this to cause an issue but I can see that Docker is binding py-kms to both the IPv4 and IPv6 stack.

Can you try disabling IPv6?

https://docs.docker.com/config/daemon/ipv6/

@Matthew-Beckett My Windows won't active unless I start Putty for a while.....I don't think it started.

Can you expand on "unless I start Putty for a while"

What does this mean?

@Matthew-Beckett It means that I must login the system.If I logout the system,it will auto stop.

@simonmicro is this being caused by dual stack being disabled by default in current builds?

@simonmicro is this being caused by dual stack being disabled by default in current builds?

Nope - it should still be active...

According to https://docs.docker.com/engine/reference/builder/#healthcheck the return value of 0 is a success?! I have no idea, why Docker considers that container as failed (health-starting indicates, that maybe the startup-time has not passed -> even upon successful checks the container is still "starting"?)... But IIRC Docker should not act upon that - you would need to use something like https://hub.docker.com/r/willfarrell/autoheal/ for that...

Maybe... I've heard that users could use systemd's user-space services... This means that a user could create a Docker service, which only runs while he is logged into the system and then stopped upon logout... Maybe that's the case here?

@simonmicro Yes, I remember that after docker installed,it asks me to create a Docker service which says "Don't need root to start docker"