# Docker api exitcode 0

**URL:** <https://forums.docker.com/t/docker-api-exitcode-0/150830>\
**Category:** General\
**Created:** [January 14, 2026, 11:45am UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830 "2026-01-14T11:45:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lennoxkus](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lennoxkus/32/60541_2.png) [@lennoxkus](https://forums.docker.com/u/lennoxkus)\
**Post date:** [January 14, 2026, 11:45am UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/1 "2026-01-14T11:45:52Z")

</div>

I want to run a API on my rasberry pi 5 with Kali Linux, but the docker instantly exits with code 0 after creating. The API should connect a locally hosted Minecraft server with a docker running the get.homepage image. The code for the API and everything you need to run it is here: [MC/DOCKER-API · GitHub](https://gist.github.com/lennoxkus-craftingdemon/02e53a4b9f394cacd7995a628d041550)  
I‘d be happy if someone could help.

---

<div class="post-metadata">

**Author:** ![lennoxkus](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lennoxkus/32/60541_2.png) [@lennoxkus](https://forums.docker.com/u/lennoxkus)\
**Post date:** [January 14, 2026, 11:47am UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/2 "2026-01-14T11:47:09Z")

</div>

The Homepage docker runs on port 3000 and the rcon port of the server is port 25575

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [January 14, 2026, 11:57am UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/3 "2026-01-14T11:57:01Z")

</div>

So if I understand it correctly, it is basically a Pyhon question, because I don’t see you returning an exit code in Python: [https://www.codecademy.com/article/python-exit-commands-quit-exit-sys-exit-os-exit-and-keyboard-shortcuts](https://www.codecademy.com/article/python-exit-commands-quit-exit-sys-exit-os-exit-and-keyboard-shortcuts)

Once it returns the right exit code, the Docker container will ass well.

> [@lennoxkus](#):
>
> with a docker running the get.homepage image

It is a Docker container. Not a Docker. When you say “a Docker”, people will think of the Docker daemon that runs the containers.

Also could you please, share the code snippets here in the topic? You can insert the code in a code block like this:

````auto
```
this is a code
```

````

Otherwise the topic will not be understandable later if the snippets disappear on GitHub for any reason in the future. Thank you!

---

<div class="post-metadata">

**Author:** ![lennoxkus](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lennoxkus/32/60541_2.png) [@lennoxkus](https://forums.docker.com/u/lennoxkus)\
**Post date:** [January 14, 2026, 12:08pm UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/4 "2026-01-14T12:08:04Z")

</div>

When I execute `docker ps -a` it gives me `0cbf705c1f6a mc-api "python api.py" 36 minutes ago Exited (0) 34 minutes ago mc-api ` the code is (its a bit bigger than you‘d think)

```auto
from datetime import datetime, timezone
import threading
import time
from flask import Flask
from mcrcon import MCRcon # pip install mcrcon

app = Flask( __name__ )

RCON_HOST = "127.0.0.1"
RCON_PORT = 25575
RCON_PASSWORD = "YourStrongPassword"
POLL_INTERVAL = 5

state = {
    "online": False,
    "players": None,
    "error": "Not checked yet",
    "checked_at": None,
}

def poll_minecraft():
    global state
    while True:
        try:
            with MCRcon(RCON_HOST, RCON_PASSWORD, port=RCON_PORT, timeout=3) as mcr:
                resp = mcr.command("list")`

                parts = resp.split()
                online = int(parts[2])
                maxp = int(parts[7])
    state = {
                    "online": True,
                    "players": {"online": online, "max": maxp},
                    "checked_at": datetime.now(timezone.utc).isoformat()
                }
        except Exception as e:
            state = {
                "online": False,
                "error": str(e),
                "checked_at": datetime.now(timezone.utc).isoformat()
            }

        time.sleep(POLL_INTERVAL)

@app.get("/status")
def status():
    return state`

```

---

<div class="post-metadata">

**Author:** ![lennoxkus](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lennoxkus/32/60541_2.png) [@lennoxkus](https://forums.docker.com/u/lennoxkus)\
**Post date:** [January 14, 2026, 12:10pm UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/5 "2026-01-14T12:10:24Z")

</div>

I cant get it as one block.this is the best i could do.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [January 14, 2026, 12:21pm UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/6 "2026-01-14T12:21:20Z")

</div>

Please, edit your post and add the code block as I described in my previous post. If you need more help, you can find our formatting guide: [How to format your forum posts](https://forums.docker.com/t/how-to-format-your-forum-posts/127295)

But you just need to add the three backtick characters before and after the code in a new line. (ALTGR+7 usually)

If you are using the WYSIWYG message composer, then use the `</>` button to add the code block. Thank you!

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/bluepuma77/32/32688_2.png) [@bluepuma77](https://forums.docker.com/u/bluepuma77)\
**Post date:** [January 14, 2026, 5:52pm UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/7 "2026-01-14T17:52:56Z")

</div>

It seems your python code is missing to start the services. So the script will just exit. I ran your script through a chatbot and simply asked to add debug information, and the bot silently added:

```auto
if __name__ == " __main__":
    print("[DEBUG] Starting poll thread")
    t = threading.Thread(target=poll_minecraft, daemon=True)
    t.start()

    print("[DEBUG] Starting Flask app")
    app.run(host="0.0.0.0", port=5000)

```

Did you ever try to run your script without a Docker container? It should have exited, too.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/docker/original/3X/d/4/d4fbccd46c81bfcffe9822e20e17736d946fa821.png) [@system](https://forums.docker.com/u/system)\
**Post date:** [February 13, 2026, 5:53pm UTC](https://forums.docker.com/t/docker-api-exitcode-0/150830/8 "2026-02-13T17:53:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
