This is the REST API reference of hyperd
based on The latest release.
- By default
hyperd
listens on unix:///var/run/hyper.sock and the client must have root access to interact with the daemon. - The current release does not support encrypted connections.
- The Remote API uses an open schema model. In this model, unknown properties in incoming messages will be ignored. Client applications need to take this in consideration to ensure they will not break when talking to newer hyperd daemons.
- Calling
/info
is the same as calling/${latest}/info
- The API tends to be RESTful, but in a few exceptions, e.g.
attach
,pull
, the HTTP connection is hijacked to transport stdout, stdin and stderr.
POST /pod/create
Create a Pod
Example request:
POST /pod/create?podArgs=****
The argument is a string, which converts the Pod's json to a string.
POST /pod/start
Start a Pod
Example request:
POST /pod/start?podId=pod-xxxxxxxxxx&vmId=vm-xxxxxxxxxx
If the VM id is empty (""), then it will create a new VM.
POST /pod/stop
Stop a Pod
Example request:
POST /pod/stop?podId=pod-xxxxxxxxxx&stopVM=yes
The stopVM
property can be yes
or no
; it will destroy the VM associated with the Pod if its value is yes
DELETE /pod
Destroy a Pod
Example request:
DELETE /pod?podId=pod-xxxxxxxxxx
GET /list
List pods
Example request:
GET /list?item=pod
GET /pod/info
Get Pod detail information
Example request:
GET /pod/info?podId=pod-xxxxxxxxxx
GET /pod/stats
Get Pod stats info
Example request:
GET /pod/stats?podId=pod-xxxxxxxxxx
POST /pod/labels
Set pod labels
Example request:
POST /pod/labels?podId=pod-xxxxxxxxxx&labels={"ll":"vv"}&override=true
POST /pod/kill
Send kill signal to containers of a Pod
Example request:
POST /pod/kill?podName=pod-xxxxxxxxxx&container=xxxxxxx&signal=9
GET /pod/{pod_id}/portmappings
Get a list of current port mappings of a pod.
PUT /pod/{pod_id}/portmappings/{action}
Update port mapping rules
action
could beadd
ordelete
The request body is an json array of PortMapping
:
{
"containerPort": "80",
"hostPort": "3000",
"protocol": "udp"
}
Where
containerPort
andhostPort
could be a single port or a range, such as "8000-8080"; and if thecontainerPort
is a range, thehostPort
should be a range in same size;protocol
could betcp
orudp
.
The request body should be an array even if there is only one rule to be added/deleted.
POST /container/create
Create a container
Example request:
POST /pod/create
The body is a container spec in JSON format.
POST /container/start
Start a container
Example request:
POST /container/start?container=xxxxxxxx
POST /container/stop
Stop a container
Example request:
POST /container/stop?container=xxxxxxxx
POST /container/kill
Kill a container with a signal
Example request:
POST /container/kill?container=xxxxxxxx&signal=9
POST /container/remove
Remove a container from Pod
Example request:
POST /container/remove?container=xxxxxxxx
POST /container/rename
Rename a container
Example request:
POST /container/rename?newName=yyyyyyy&oleName=xxxxxxxx
GET /list
List containers
Example request:
GET /list?item=container
GET /container/info
Get container info
Example request:
GET /container/info?container=xxxxxxxx
GET /container/logs
Get container logs
Example request:
GET /container/logs?container=xxxxxxxx&stdout=true&stderr=true&follow=false×tamp=true&tail=100
GET /container/exitcode
Example request:
GET /container/exitcode?container=xxxxxxxx&exec=eeeeeeeee
POST /container/commit
Example request:
POST /container/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
Content-Type: application/json
{
"Hostname": "",
"Domainname": "",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 512,
"Cpuset": "0,1",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"PortSpecs": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Volumes": {
"/tmp": {}
},
"WorkingDir": "",
"NetworkDisabled": false,
"ExposedPorts": {
"22/tcp": {}
}
}
POST /attach
Attach to a container, will upgrade to TCP stream.
POST /tty/resize
Change the tty window size of container or exec
Example request:
POST /tty/resize?container=xxxxxxxx&exec=eeeeeeeee&h=25&w=80
POST /exec/create
Create an exec
Example request:
POST /exec/create?container=xxxxxxxx&tty=true&command=/bin/bash
POST /exec/start
Start an exec
Example request:
POST /exec/start?container=xxxxxxxx&exec=eeeeeeeee
The exec request will upgrade to TCP stream
GET /info
Display system-wide information
Example request:
GET /info
GET /images/get
Get images' list
Example request:
GET /images/get?all=yes
Query Parameters:
all – yes or no, default no
POST /image/create
Create an image, either by pulling it from the registry or by importing it
Example request:
POST /image/create?imageName=ubuntu HTTP/1.1
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{"status": "Pulling..."}
{"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
{"error": "Invalid..."}
...
When using this endpoint to pull an image from the registry, the
`X-Registry-Auth` header can be used to include
a base64-encoded AuthConfig object.
Query Parameters:
imageName – name of the image to pull
Request Headers:
X-Registry-Auth – base64-encoded AuthConfig object
DELETE /image
Remove an image
Example request:
DELETE /image?imageId=xxxxxxxxxxxx
Query Parameters:
force – yes or no, default no
noprune – yes or no, default no
POST /image/build
Example request:
POST /image/build HTTP/1.1
{{ TAR STREAM }}
The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
The archive must include a build instructions file, typically called Dockerfile
at the root of the archive. The dockerfile
parameter may be used to specify a different build instructions file by having its value be the path to the alternate build instructions file to use.
The archive may include any number of other files, which will be accessible in the build context.
Query Parameters:
dockerfile - path within the build context to the Dockerfile
t – repository name (and optionally a tag) to be applied to the resulting image in case of success
remote – git or HTTP/HTTPS URI build source
q – suppress verbose build output
nocache – do not use the cache when building the image
pull - attempt to pull the image even if an older image exists locally
rm - remove intermediate containers after a successful build (default behavior)
forcerm - always remove intermediate containers (includes rm)
Request Headers:
Content-type – should be set to "application/tar".
X-Registry-Config – base64-encoded ConfigFile object
POST /image/push
Push the image on the registry
Example request:
POST /images/push?remote=test
Query Parameters:
remote - the image on the registry
tag – the tag to associate with the image on the registry, optional
Request Headers:
X-Registry-Auth – include a base64-encoded AuthConfig object.
POST /auth
Get the default username and email
Example request:
POST /auth HTTP/1.1
Content-Type: application/json
{
"username":"hello",
"password: "world",
"email": "[email protected]",
"serveraddress": "https://index.docker.io/v1/"
}