brianmiller / phvalheim-server

PhValheim backend server
GNU General Public License v2.0
26 stars 5 forks source link

Docker Unraid not available #22

Closed SaschMie closed 1 year ago

SaschMie commented 1 year ago

Hi there,

i have a problem with that docker image:

image

It always says not available.

image

What is the problem here? This is the only docker with that problem.

BionicAlice commented 1 year ago

I had this bug as well. After a bit of googling seems like others have had issues with single dockers. It has to do something with unraid docker networks . I have custom networks for other things. So what I did was switch the PhValheim-Server docker to a custom network , force updated it after that. Put it back on bridge as the network and now it functions correctly.

brianmiller commented 1 year ago

The "not available" is Unraid not being able to determine if a container update is available--that's it. You can just "force update" to pull another copy/latest version.

I don't know why some containers can't determine if an update is available. Coincidentally, I was debugging this last night. I think I need to speak with the Community Applications folks to understand wtf is going on with their update checker.

brianmiller commented 1 year ago

I posted in the public forum for help: https://forums.unraid.net/topic/132686-docker-updateversion-not-available/

I also have a private chat with Squid (the CA mod guy for Unraid)

BionicAlice commented 1 year ago

Thanks for looking into it . Seems like the solution I got was just a temp GUI fix until an update check is run.

brianmiller commented 1 year ago

The issue has been resolved. This isn't a CA or unRAID issue. It's OCI compatibility with DockerHub.

My Unraid forum post: https://forums.unraid.net/topic/132686-docker-updateversion-not-available/

I figured it out.

My debugging process:

I grepped through the entire directory /usr/local/emhttp/plugins/dynamix.docker.manager/include for "not available" which is the HTML label shown in the Unraid Docker UI

image

To prove to myself that I found the right label, I added the "!" you see in the screenshot above. This label is inside a case/switch condition. I.e., 0="up-to-date", 1="update ready", 2="rebuild ready" else, "not available" within the DockerContainers.php file. My containers were returning a NULL value which results in the "default/else" (not available message). This condition evaluates the variable "$updateStatus". This variable is set by an array read of the $info['updated'] array element. This variable is set by DockerClient.php and where most of my debugging occurred.

/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php: I added the following to the "getRemoteVersionV2" function to assist in debugging.

$file = '/tmp/foo.txt';
file_put_contents($file, PHP_EOL . $image . '(' . $manifestURL . ')' . '   ', FILE_APPEND);

This sent me on a reverse engineering journey and helped me create a little test script:

#!/bin/bash
repo="theoriginalbrian/phvalheim-server"
TOKEN=$(curl --silent "https://auth.docker.io/token?scope=repository:$repo:pull&service=registry.docker.io" | jq -r '.token')
curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/$repo/manifests/latest"

The output of this little test script:

{"errors":[{"code":"MANIFEST_UNKNOWN","message":"OCI manifest found, but accept header does not support OCI manifests"}]}

A bit of research landed me in DockerHub API documentation...in short, OCI images do not contain the SHA256 image digest (at least in the location DockerHub expects).

This led me to look at how I'm building my images. My dev system is just a simple Rocky 8.6 (EL) VM, which runs podman. By default, podman builds in the OCI format. Simply passing "--format=docker" to my podman build command solved the issue.

Results:

After clicking "check for updates": image

After clicking "apply update": image

After clicking "apply update" and "check for updates:" image

TL;DR: add "--format=docker" to your docker/podman build command.

-Brian

BionicAlice commented 1 year ago

Really appreciate all the work you put into this and thank you for the explanation