passing args to container through docker API - api

I want to create and start a docker container with some arguments (to the CMD) through docker API using a json file.
curl -XPOST --unix-socket /var/run/docker.sock -d #minio.json -H 'Content-Type: application/json' http://localhost/containers/create?name=minio
curl -XPOST --unix-socket /var/run/docker.sock -H 'Content-Type: application/json' http://localhost/containers/minio/start
I tried to put them in the top of the json and the HostConfig "sub entry"
"Args": "server --address 192.168.150.3:80 /export",
but when I inspect the arguments are not there.
In the documentation there are examples only when you inspect a container and see the arguments.
Is there a way to pass Args within the json file or when you start the container with curl and a payload ("docker run" is excluded) ?
UPDATE:
Solution is to list all arguments in double quotes in the array.
"Cmd": [
"server" ,"--address", "192.168.100.8:8888", "/export"
],

The API has two attributes in JSON
"Cmd": [
"date"
],
"Entrypoint": "",
You need to change the Cmd array to pass the arguments you want

Related

I can't disable the user with the Keyrock API

I want to disable or enable the user found in keyrock with API, but I can't. https://keyrock.docs.apiary.io/ doesn't say how to do it here. Isn't that possible?enter image description here
Log in as an admin user via the REST API.
curl -iX POST \
'http://localhost:3005/v1/auth/tokens' \
-H 'Content-Type: application/json' \
-d '{
"name": "admin#test.com",
"password": "1234"
}'
The response header returns an X-Subject-token Header which identifies who has logged on the application. This token is required in all subsequent requests to gain access.
The image you give in the question is just a GUI version of the GET /users endpoint
curl -L -X GET 'http://localhost:3005/v1/users' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Or you can request a specific user:
curl -L -X GET 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Returns:
{
"user": {
"scope": [],
"id": "bbbbbbbb-good-0000-0000-000000000000",
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": true,
"admin": false,
"image": "default",
"gravatar": false,
"date_password": "2018-07-30T11:41:14.000Z",
"description": "Bob is the regional manager",
"website": null
}
}
You want to set enabled: false using the PATCH /user endpoint.
curl -L -X PATCH 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
--data-raw '{
"user": {
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": false,
"gravatar": false,
"date_password": "2018-07-26T15:25:14.000Z"
}
}'
More information can be found within the Security Chapter Tutorials
within the FIWARE documentation where Keyrock is a component found within the FIWARE Catalogue
In the FIWARE documentation an example is given using Keyrock to provide user identities around a "powered by FIWARE" solution. Note that whilst Keyrock is commonly used in "powered by FIWARE" solutions (along with other elements from the FIWARE Catalogue), it could also be used to provide identities for other independent applications or micro-services - it is not tightly bound to only be used in FIWARE scenarios. Similarly alternative open-source or proprietary components for security or identity management systems could be used to secure "powered by FIWARE" solution as well.

Cannot create new Pipeline using Az DevOps Pipelines API 6.0-preview.1

I'm trying to create new Pipelines using this API endpoint:
POST https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=6.0-preview.1
This is the request I'm using:
curl -X POST \
'https://dev.azure.com/<myorg>/<myproj>/_apis/pipelines?api-version=6.0-preview.1' \
-H 'Authorization: Basic <b64string>' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"configuration":{
"repository": {
"id": "<repo-guid>",
"name": "<repo-name>",
"type": "azureReposGit"
},
"path": "pipeline.yaml",
"type": "yaml"
},
"folder": "\\custompath\\",
"name": "<pipelinename>"
}
I keep getting the same error:
{
"$id": "1",
"innerException": null,
"message": "Value cannot be null.\r\nParameter name: repositoryName",
"typeName": "System.ArgumentNullException, mscorlib",
"typeKey": "ArgumentNullException",
"errorCode": 0,
"eventId": 0
}
It seems an issue with my payload, but documentation isn't very helpful about it
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.0
Current version o nodejs sdk doesn't support the Pipeline API yet. Can anyone help me?
I'm able to reproduce your issue on my side, and have reported this issue at website below:
https://developercommunity.visualstudio.com/content/problem/1101376/create-pipeline-rest-api-does-not-work.html
Product team has provided response that "A fix for this issue has been prepared. It should be released to everyone within the next 3 weeks."

Creating a tag with the Bitbucket Server API fails

I'm trying to use the Bitbucket Server RST API to create a new tag for a specific commit (represented by a hash). Please note that I use basic auth but don't write it to my examples below. What I've got is an HTTP 500 response.
curl -XPOST 'http://<server>/rest/api/latest/projects/p1/repos/r1/tags' -d '{
   "name": "my-new-tag",
    "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}'
I also tried:
curl -XPOST 'http://<server>/2.0/repositories/username/r1/refs/tags' -d '{
   "name": "my-new-tag",
    "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}'
But in this case the request ends up in an HTTP 404 and I think that's because this is not a Bitbucket Server URL.
You can try this way:
curl -X POST -k -H 'Content-Type: application/json' -s -u <Your Account>:<Your password> -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{
"name": "my-new-tag",
"target":{
"hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}
}'
or
curl -X POST -k -H 'Content-Type: application/json' Authorization: Basic <<Authentication String>>' -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{
"name": "my-new-tag",
"target":{
"hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}
}'

Icinga2 API - get specific hosts from templates

How can i set my filters to get only the hosts from a template, which have a custom variable set to true?
With this curl, im getting all hosts in the template but not the ones, which have set the custom_var true
curl -k -s -u $apiuser:$apipassword -H 'Accept: application/json' -X
POST -H 'X-HTTP-Method-Override: GET' https://$url:$port/v1/objects
/hosts -d '{ "filter": "\"template\" in host.templates",
"filter_vars": { "custom_var": true } } ' | jq '.'
Any ideas on how can i get the specific hosts?
Finally got i working. I edited my filter as follows:
-d '{ "filter": "\"template\" in host.templates && host.vars.custom == true" } ''' | jq '.'

ICINGA2 API Not making host modification

i have problem with the API of ICINGA2.
i'm trying to add new variables with the POST call ,
i'm getting the required result,
But ICINGA2 didn't add the new var.
According to documentation:
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/icinga2-api
With the following API, i creates all our hosts in vienna :
curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh" } }' \
| python -m json.tool
While this part works as expected,
The problem is once host created, i need to add various vars for different servers.
for example
Adding of the variable: "vars.servicename" : "DHCP_Servers"
If i'm going back to the documentation, the below API that will need to be execute:
curl -k -s -u root:icinga -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh", "vars.servicename" : "DHCP_Servers" } }' \
| python -m json.tool
When i ran the API , as expected i'm getting back:
{
"results": [
{
"code": 200.0,
"name": "server.example.com",
"status": "Attributes updated.",
"type": "Host"
}
]
}
But there is no changes that taking place on ICINGA/ host file.
Obviously the same user as in my inbox and the forums (https://monitoring-portal.org/index.php?thread/37160-adding-vars-with-api/&postID=234885#post234885) lately. Leaving this as a note here as it might help others to see why it does not work. That feature is just not implemented as it involves storing the applied changes, do a rollback, and re-apply. Not as simple as it sounds.
https://dev.icinga.org/issues/11501