How to execute "docker checkpoint create container_id checkpoint_id" using curl? - docker

At the moment of writing, docker checkpoint feature is still in experimental phase so there is no official (HTTP) API documentation. Nonetheless, there is an endpoint on the docker daemon that can accept an HTTP request, as it is the one that docker cli uses.
Based on the related docker source code it should be something like
sudo curl -X POST --unix-socket /var/run/docker.sock http://localhost/v1.32/containers/20fb4f16ff10/checkpoints
but this does not work. Any ideas what I may be missing?

The create options is missing.
curl --unix-socket /var/run/docker.sock \
-H "Content-Type: application/json" \
-d '{"CheckpointID": "noting"}' \
-X POST http:/v1.32/containers/20fb4f16ff10/checkpoints

Related

Is there a way to get tags of a docker image on github container registry (ghcr.io) via curl or gh command?

Is there a way to get tags of a docker image on github container registry via curl or gh command?
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/${ORG}/packages/container/${CONTAINER_IMG}
I have tried above but it does not give me docker tags for the iamge.
I am expecting to get the docker tags of ghcr.io containers.

TensorFlow model server - Could not resolve host POST

I am new to TensorFlow (using 1.13) and trying to build a TF model and serve it on a docker tensor flow model server.
I have exported my model, installed docker and started my docker container with the command:
docker run -p 8501:8501 --name SN_TFlow
--mount type=bind,source=/tmp/service_model/export,target=/models
-e MODEL_NAME=1596551653 -t tensorflow/serving &
I can see my container running and the line: "I tensorflow_serving/model_servers/server.cc:375] Exporting HTTP/REST API at:localhost:8501 ..." in the client which seems to indicate all is up and running according to the doc.
However when I try to test my model with the curl command:
$ curl -d ‘{"test_value": [40]}' \ -X POST http://localhost:8501/1/models/1596551653:predict
I get a message saying:
URL bad/illegal format or missing url
Could not resolve host POST
and I get a 404 message.
I also tried simply curl http://localhost:8501/models/1/1596551653 but also get Not found.
Any idea what I am missing? Thanks
The problem I observe in your code is the \ in the middle of the curl command.
The backslash, \ should occur at the end of the line, if the command is more than one line.
So, the below command,
$ curl -d ‘{"test_value": [40]}' \ -X POST
http://localhost:8501/1/models/1596551653:predict
should be changed as shown below (move the backslash to the end) :
$ curl -d ‘{"test_value": [40]}' -X POST \
http://localhost:8501/1/models/1596551653:predict
Also, we suggest you to upgrade to the Latest Version of Tensorflow in 1.x, which is 1.15 or to 2.3.0.

Docker exec. How to use shell-commands in container without entering?

Can someone explain me, how can I use sh-commands inside container without enter that container?
I use a shell script at my host. I want this shell-script to enter one of my container and then curl post to another container through overall network. So, my problem is that when i tring to do something like:
docker exec -ti nodejs sh "curl -X POST \
http://tgbot:3017/deploy \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache' \
-d 'message=Prod has been updated!'"
I have in console:
sh: 0: Can't open curl -X POST http://tgbot:3017/ -H 'Content-Type: application/x-www-form-urlencoded' -H 'cache-control: no-cache' -d 'message=Prod has been updated!'
failed to resize tty, using default size
Or mayby I can curl into docker network right from host somehow?
You can just use Docker exec command on the host machine.
docker exec -it <container name> <command>

List Repository names on Docker Hub

Is there any docker command to only list the names of repositories in docker hub registry?
I didn't find any on docker.io platform.
It's not supported by default, but you can make your own script that contains multiple function in order to list repo names as well as the images within your acccount.
It can be a simple Bash Script or can embedded to your app as a tool to search repos.
Get your authToken by login to dockerHub
Using the authToken you can invoke repo listing under your account.
AuthToken=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${username}'", "password": "'${password}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -H "Authorization: JWT $AuthToken" https://hub.docker.com/v2/repositories/${username}/?page_size=100 | jq -r '.results|.[]|.name'
I refer to this script from github.

Docker API /images/json always returns Containers:-1

As stated in the API docs
https://docs.docker.com/engine/api/v1.39/#operation/ImageList
an image should contain something like "Containers": 2 but for me, all images returned by the api have "Containers": -1 eventhough there are containers running that use the image
(checked with docker ps -a)
I'm running Docker Engine 18.09.2 with API version 1.39
I tested the image listing with the node package dockerode and with the curl commands
sudo curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" http:/docker/images/json
and
sudo curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" http:/v1.39/images/json

Resources