Docker Hub: Remote Build Trigger doesn't work - docker

I am trying to trigger image build via remote build trigger URL.
I have followed the Docker Hub documentation, but the actual Docker Hub UI option doesn't have the same options as described in the Docker Hub Docs for remote build trigger.
Docker Hub interface shown as per the docs:
My Docker Hub Interface:
I don't see token option anywhere.
Also, I tried hitting the trigger URL directly via browser, but that doesn't help either.
I guess I haven't understand this correctly, or there is some serious bug in Docker Hub especially for remote build trigger.

It seems you are following some unofficial documentation, which is outdated. Docker Hub redesigned this part some time ago. Now you don't need a token, because it's already included in the URL. But opening it in the browser is not enough, it must be a POST request, so you can try that from the command line with curl for example:
curl -X POST "<the-trigger-url-here>"

Related

Adding ghcr (Github Docker Regustry) to Synology docker results in "Registry returned bad result"

When trying to add the Github Registry to Synology Docker, I always get a prompt saying "Registry returned bad result".
The URL I try to connect to is: https://ghcr.io
I'm trying to do the same (DS920+, DSM 7.1 latest). According to this Reddit:
https://www.reddit.com/r/portainer/comments/u1vf1s/how_to_add_ghcr_as_a_registry/
it used to work with 'docker.pkg.github.com' as the repo url, but according to the current Github docs, it was the old namespace and the actual repo is now 'https://ghcr.io'
https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
According to the docs, authentication is implied many times, maybe it is not possible to use the repo w/o authentication (tried with access tokens, not working).
I opened a Synology support ticket, let's see what they can say.
2022-10-27 - Synology Support replied and the official statement is that the token authentication currently used by Github Container Registry is not supported on the DSM's Docker package GUI. Its possible to ssh to the DSM and use docker from the command line.

How to configure docker/docker-compose to use Nexus by default instead of docker.io?

I'm trying to use TestContainers to run JUnit tests.
However, I'm getting a InternalServerErrorException: Status 500: {"message":"Get https://registry-1.docker.io/v2/: Forbidden"} error.
Please note, that I am on a secure network.
I can replicate this by doing docker pull testcontainers/ryuk on the command line.
$ docker pull testcontainers/ryuk
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: Forbidden
However, I need it to pull from our nexus service: https://nexus.company.com/18443.
Inside the docker-compose file, I'm already using the correct nexus image path. (Verified by manually starting it with docker-compose. However TestContainers also pulls in additional images which are outside the docker-compose file. It is these images that are causing the failure.
I'd be glad for either a Docker Desktop or TestContainers configuration change that would fix this for me.
Note: I've already tried adding the host URL for nexus to the Docker Engine JSON configuration on the dashboard, with no change to the resulting error when doing docker pull.
Since the version 1.15.1 Testcontainers allow to automatically append prefixes to all docker images. In case your private registry is configured as a docker hub mirror this functionality should help with the mentioned issue.
Quote from the documentation:
You can then configure Testcontainers to apply the prefix registry.mycompany.com/mirror/ to every image that it tries to pull from Docker Hub. This can be done in one of two ways:
Setting environment variables TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX=registry.mycompany.com/mirror/
Via config file, setting hub.image.name.prefix in either:
the ~/.testcontainers.properties file in your user home directory, or
a file named testcontainers.properties on the classpath
Basically set the same prefix you did for the images in your docker-compose file.
If you're stuck with older versions for some reason, a deprecated solution would be to override just the ryuk.container.image property. Read about it here.
The process is described on this page:
Add the following to your Docker daemon config:
{
"registry-mirrors": ["https://nexus.company.com:18443"]
}
Make sure to restart the daemon to apply the changes.

Programmatically get docker manifest

I’m using the aws-sdk for nodejs for pushing a docker image to the aws ecr using this call:
https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_PutImage.html#API_PutImage_RequestSyntax
In code the sdk asks for the docker manifest which I don’t understand. I don’t have a way to get the manifest through dockerode (the npm package I use for talking to the docker api) and the ‘docker manifest’ cli command seems to be epirimental. How do I get the manifest, which is a json document described here:
https://docs.docker.com/registry/spec/manifest-v2-1/
I might be on the wrong track. It says in the documentation:
This operation is used by the Amazon ECR proxy, and it is not intended
for general use by customers for pulling and pushing images. In most
cases, you should use the docker CLI to pull, tag, and push images.
So I may not be able to use this as I intended

How to list images in docker registry being on registry server?

Currently I'm pushing images from one machine to another. The success of it I can determine base on HTTP status from pushing machine or base on logs from the registry server. At this point I want to search through what really is in my registry on my server. What I found till now is the API calls from outside and that if even when you call it you have to know exact name of the image and how it is tagged. In my case, I want just to enlist what images currently are in my registry when I have direct access to it. I did not find any related command.
The docker CLI doesn't have functionality to search a registry, but you can use the registry's REST API. Assuming you're using the registry:2 image, then you can list all the repositories using the catalog endpoint:
curl https://my-registry:5000/v2/_catalog
{"repositories":["busybox","redis","ubuntu"]}
And then you can query the tags for a repository:
curl https://my-registry:5000/v2/busybox/tags/list
{"name":"busybox","tags":["2","latest"]}
Here's the full Registry API spec.

docker --add-hosts flag equivalent in remote API?

I want to use the --add-hosts flag in the docker remote API.
https://docs.docker.com/reference/run/#network-settings
--add-host="" : Add a line to /etc/hosts (host:IP)
This is an option for docker run so I assumed it would be possible to pass it to /containers/create in the remote API.
https://docs.docker.com/reference/api/docker_remote_api_v1.16/#create-a-container
Is there a remote API equivalent for this flag yet?
By looking in the Docker source, I can see it's called ExtraHosts.
Update: now in the docs also.

Resources