Container

Create a container

POST /api/v1/container

Create a new container.

Request JSON Object:
 
  • name (string) – container name [required]
  • image (string) – image name [required]
  • tag (string) – image tag. For LXC is latest [required]
  • type (string) – lxc, docker [required]

Request in JSON format

Key Type LXC Docker Description
type String v v ‘lxc’ or ‘docker’
name String v v Assign a name to the container
image String v v Assign a base image to the container
tag String v v lxc is ‘latest’
autostart Boolean v(e) v(e) Automatically start the container after reboot
privileged Boolean   v Give extended privileges to this container
entrypoint String   v Overwrite the default ENTRYPOINT of the image
command String   v Run a command in container
user String   v Username or UID
working_dir String   v Working directory inside the container
environment Str Array   v Set environment variables
links Object   v Add link to another container in the form of name:alias
network        
dns Str Array   v Set custom DNS servers
expose_port Int Array   v Expose a port from the container without publishing it to your host
hostname String   v Container host name. Conflict with network ‘host’ mode.
mac_addr String v v Assign MAC address to the container
port Array v(e) v Publish a container’s port to the host
mode String v v

LXC: ‘nat’, ‘bridge’

Docker: ‘nat’, ‘host’, ‘bridge’

interface String   v Ethernet interface
join Boolean   v Join to existed interface bridge
resource        
limit        
cpuweight Int v(e) v(e) 2~1024 in relative share of CPU time
cputime Int v(e) v(e) 10~999 in milliseconds(ms)
memory String v(e) v(e) String with ‘m’ in MB. Must higher than 64m
device Str Array v(e) v(e) Add a host device to the container
volume        
host Object v(e) v Mount a volume from host shared folders
container Str Array   v Mount volumes from the specified container
new Str Array   v Mount a new volume

Note

Input check for name
  • ^([a-zA-Z0-9][a-zA-Z0-9-_.]{1,63})$
    only [a-zA-Z0-9][a-zA-Z0-9-_.] are allowed, size between 2 and 64
Input check for image
  • Format: namespace/name or name
  • namespace ^([a-z0-9_]{4,30})$
    only [a-z0-9_] are allowed, size between 4 and 30
  • name ^([a-z0-9-_.]+)$
    only [a-z0-9-_.] are allowed

Example request of LXC

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "type": "lxc",
        "name": "utest",
        "image": "ubuntu-bionic",
        "tag": "latest",
        "autostart": true,
        "network": {
            "port": [
                [
                    12345,
                    1234,
                    "udp"
                ]
            ]
        },
        "resource": {
            "device": [
                [
                    "allow",
                    "video4linux_(81)",
                    "rw"
                ]
            ],
            "limit": {
                "cputime": 512,
                "cpuweight": 512,
                "memory": "768m"
            }
        },
        "volume": {
            "host": {
                "/test/selenium": {
                    "bind": "/mnt/vol1",
                    "ro": true
                },
                "/test/spec": {
                    "bind": "/mnt/vol2",
                    "ro": false
                }
            }
        }
    }' http://${QIP}:${QPORT}/container-station/api/v1/container

$ curl -sq -XPOST -b cookies.txt -d \
    '{"type": "lxc", "name": "utest", "image": "ubuntu-bionic", "tag": "latest"}' \
    http://${QIP}:${QPORT}/container-station/api/v1/container

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "type":"lxc",
        "image":"ubuntu-bionic",
        "tag":"18.04",
        "name":"utest",
        "network":{
            "mode":"bridge",
            "bridge":{
                "mode":"dhcp",
                "interface":{
                    "bridge":"br0",
                    "name":"eth0"
                }
            }
        }
    }' \
    http://${QIP}:${QPORT}/container-station/api/v1/container

Example response of LXC

{
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "name": "utest",
    "state": "stopped",
    "tcpPort": [],
    "type": "lxc"
}
{
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "name": "utest",
    "state": "stopped",
    "tcpPort": [],
    "type": "lxc"
}

Example request of Docker

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "type": "docker",
        "name": "DockerTestAPI",
        "image": "ubuntu",
        "tag": "latest",
        "autostart": false,
        "privileged": true,
        "entrypoint": "cat",
        "command": "/etc/passwd",
        "environment": [
            "QPORT=90",
            "QIP=1.2.3.4"
        ],
        "network": {
            "hostname": "CustomHostName",
            "port": [
                [
                    12345,
                    1234,
                    "udp"
                ]
            ]
        },
        "resource": {
            "limit": {
                "cputime": 512,
                "cpuweight": 512,
                "memory": "768"
            }
        },
        "volume": {
            "host": {
                "/test/selenium": {
                    "bind": "/mnt/vol1",
                    "ro": true
                },
                "/test/spec": {
                    "bind": "/mnt/vol2",
                    "ro": false
                }
            }
        }
    }' http://${QIP}:${QPORT}/container-station/api/v1/container

$ curl -sq -XPOST -b cookies.txt -d \
    '{"type": "docker", "name": "DockerTestAPI2", "image": "ubuntu", "tag": "latest"}' \
    http://${QIP}:${QPORT}/container-station/api/v1/container

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "type":"docker",
        "image":"ubuntu",
        "tag":"latest",
        "name":"DockerTestAPI3",
        "network":{
            "mode":"bridge",
            "bridge":{
                "mode":"dhcp",
                "interface":{
                    "bridge":"br0",
                    "name":"eth0"
                }
            }
        },
        "autostart":true,
        "repository":"local",
        "command":"/bin/bash"
    }' \
    http://${QIP}:${QPORT}/container-station/api/v1/container

Example response of Docker

{
    "id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
    "name": "DockerTestAPI",
    "type": "docker"
}
{
    "id": "0f7bfee7f449aa24fff25cceb3dd994d9fc65a2e59a859acd9ce49c5a0356c1f",
    "name": "DockerTestAPI2",
    "type": "docker"
}

List containers

GET /api/v1/container
Response JSON Object:
 

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container

Example response

[
    {
        "externalIP": "",
        "id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
        "image": "ubuntu:latest",
        "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
        "name": "DockerTestAPI",
        "networkMode": "",
        "project": "",
        "projectPath": "",
        "state": "stopped",
        "tcpPort": [],
        "type": "docker"
    },
    {
        "cpu": 0.0,
        "externalIP": "",
        "id": "0f7bfee7f449aa24fff25cceb3dd994d9fc65a2e59a859acd9ce49c5a0356c1f",
        "image": "ubuntu:latest",
        "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
        "ipaddress": [
            "10.0.3.5"
        ],
        "memory": 1507328,
        "name": "DockerTestAPI2",
        "networkMode": "",
        "project": "",
        "projectPath": "",
        "rx": 0,
        "state": "running",
        "tcpPort": [],
        "tx": 0,
        "type": "docker"
    },
    {
        "cpu": 8.454514710855597e-05,
        "id": "ctest",
        "image": "ubuntu-bionic:latest",
        "ipaddress": [
            "10.0.3.239"
        ],
        "memory": 44269568,
        "name": "ctest",
        "rx": 70,
        "state": "running",
        "tcpPort": [],
        "tx": 0,
        "type": "lxc"
    },
    {
        "cpu": 0.0,
        "externalIP": "",
        "id": "d59bf8a8b229d106341513afef757e076163fd5a92640c8379651bb9214d64fa",
        "image": "ubuntu:latest",
        "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
        "ipaddress": [
            "10.0.3.2"
        ],
        "memory": 884736,
        "name": "dtest",
        "networkMode": "",
        "project": "",
        "projectPath": "",
        "rx": 0,
        "state": "running",
        "tcpPort": [],
        "tx": 0,
        "type": "docker"
    },
    {
        "cpu": 0.0,
        "externalIP": "",
        "id": "54cf958bc1e3ba5280c74d64ddce3193861161b90b8de7cd4f30ed028b5151f2",
        "image": "mariadb:10.2",
        "imageID": "sha256:ee1f276f080220ce22db6e607f464e042570515b1b3d3ae03361db1ccef08b46",
        "ipaddress": [
            "10.0.3.3"
        ],
        "memory": 84705280,
        "name": "joomla_db_1",
        "networkMode": "",
        "project": "joomla",
        "projectPath": "/share/CACHEDEV1_DATA/.qpkg/container-station/ctstation/config/../../data/application/joomla",
        "rx": 0,
        "state": "running",
        "tcpPort": [],
        "tx": 0,
        "type": "docker"
    },
    {
        "cpu": 0.0,
        "externalIP": "",
        "id": "00fe35007893c2c1638f2296eba6779bc3d9b95e849d981514a31a06010f18ac",
        "image": "edhongcy/joomla-without-database:3.8.13",
        "imageID": "sha256:9f803929e90be12311e8a85fea58b495fe78ab19c291fe56ae9d9556dfed8995",
        "ipaddress": [
            "10.0.3.4"
        ],
        "memory": 26771456,
        "name": "joomla_web_1",
        "networkMode": "",
        "project": "joomla",
        "projectPath": "/share/CACHEDEV1_DATA/.qpkg/container-station/ctstation/config/../../data/application/joomla",
        "rx": 0,
        "state": "running",
        "tcpPort": [
            10082
        ],
        "tx": 0,
        "type": "docker"
    },
    {
        "cpu": 0.00016949152542372882,
        "id": "utest",
        "image": "ubuntu-bionic:latest",
        "ipaddress": [
            "10.0.3.240"
        ],
        "memory": 44630016,
        "name": "utest",
        "rx": 0,
        "state": "running",
        "tcpPort": [],
        "tx": 70,
        "type": "lxc"
    }
]

Inspect a container

GET /api/v1/container/(string: container_type)/(string: container_id)/inspect

Return low-level information on a container.

Example request of LXD

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/<container_id>/inspect

Example response of LXD

{
    "NetworkSettings": {
        "Ports": {}
    }
}

Example request of Docker

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/inspect

Example response of Docker

{
    "AppArmorProfile": "",
    "Args": [
        "/etc/passwd"
    ],
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [
            "/etc/passwd"
        ],
        "Domainname": "",
        "Entrypoint": [
            "cat"
        ],
        "Env": [
            "QPORT=90",
            "QIP=1.2.3.4",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "ExposedPorts": {
            "1234/udp": {}
        },
        "Hostname": "CustomHostName",
        "Image": "ubuntu:latest",
        "Labels": {
            "com.qnap.qcs.gpu": "False",
            "com.qnap.qcs.network.mode": "nat"
        },
        "OnBuild": null,
        "OpenStdin": true,
        "StdinOnce": false,
        "Tty": true,
        "User": "",
        "Volumes": null,
        "WorkingDir": ""
    },
    "Created": "2021-08-11T08:51:46.426233605Z",
    "Driver": "overlay2",
    "ExecIDs": null,
    "GraphDriver": {
        "Data": {
            "LowerDir": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/overlay2/6e1b148f9f1b91aafa90fcb29a2d386d1ee6e578fbf151aa6fbf8295f617b33a-init/diff:/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/overlay2/b682268b56d8843a9a70a385892bc6009967ea021b34656781b062adaddf3af1/diff",
            "MergedDir": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/overlay2/6e1b148f9f1b91aafa90fcb29a2d386d1ee6e578fbf151aa6fbf8295f617b33a/merged",
            "UpperDir": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/overlay2/6e1b148f9f1b91aafa90fcb29a2d386d1ee6e578fbf151aa6fbf8295f617b33a/diff",
            "WorkDir": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/overlay2/6e1b148f9f1b91aafa90fcb29a2d386d1ee6e578fbf151aa6fbf8295f617b33a/work"
        },
        "Name": "overlay2"
    },
    "HostConfig": {
        "AutoRemove": false,
        "Binds": [
            "/share/test/selenium:/mnt/vol1:ro",
            "/share/test/spec:/mnt/vol2:rw"
        ],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeight": 0,
        "BlkioWeightDevice": null,
        "CapAdd": null,
        "CapDrop": null,
        "Cgroup": "",
        "CgroupParent": "",
        "CgroupnsMode": "host",
        "ConsoleSize": [
            0,
            0
        ],
        "ContainerIDFile": "",
        "CpuCount": 0,
        "CpuPercent": 0,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpuShares": 512,
        "CpusetCpus": "",
        "CpusetMems": "",
        "DeviceCgroupRules": null,
        "DeviceRequests": null,
        "Devices": null,
        "Dns": null,
        "DnsOptions": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "GroupAdd": null,
        "IOMaximumBandwidth": 0,
        "IOMaximumIOps": 0,
        "IpcMode": "private",
        "Isolation": "",
        "KernelMemory": 0,
        "KernelMemoryTCP": 0,
        "Links": null,
        "LogConfig": {
            "Config": {
                "max-file": "10",
                "max-size": "10m"
            },
            "Type": "json-file"
        },
        "MaskedPaths": null,
        "Memory": 805306368,
        "MemoryReservation": 0,
        "MemorySwap": 1610612736,
        "MemorySwappiness": null,
        "NanoCpus": 0,
        "NetworkMode": "bridge",
        "OomKillDisable": false,
        "OomScoreAdj": 0,
        "PidMode": "",
        "PidsLimit": null,
        "PortBindings": {
            "1234/udp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "12345"
                }
            ]
        },
        "Privileged": true,
        "PublishAllPorts": false,
        "ReadonlyPaths": null,
        "ReadonlyRootfs": false,
        "RestartPolicy": {
            "MaximumRetryCount": 0,
            "Name": ""
        },
        "Runtime": "runc",
        "SecurityOpt": [
            "label=disable"
        ],
        "ShmSize": 67108864,
        "UTSMode": "",
        "Ulimits": [
            {
                "Hard": 65535,
                "Name": "nofile",
                "Soft": 65535
            }
        ],
        "UsernsMode": "",
        "VolumeDriver": "",
        "VolumesFrom": null
    },
    "HostnamePath": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/containers/5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535/hostname",
    "HostsPath": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/containers/5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535/hosts",
    "Id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
    "Image": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
    "LogPath": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/containers/5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535/5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535-json.log",
    "MountLabel": "",
    "Mounts": [
        {
            "Destination": "/mnt/vol1",
            "Mode": "ro",
            "Propagation": "rprivate",
            "RW": false,
            "Source": "/share/test/selenium",
            "Type": "bind"
        },
        {
            "Destination": "/mnt/vol2",
            "Mode": "rw",
            "Propagation": "rprivate",
            "RW": true,
            "Source": "/share/test/spec",
            "Type": "bind"
        }
    ],
    "Name": "/DockerTestAPI",
    "NetworkSettings": {
        "Bridge": "lxcbr0",
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "",
        "Networks": {
            "bridge": {
                "Aliases": null,
                "DriverOpts": null,
                "EndpointID": "",
                "Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": null,
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "",
                "NetworkID": "be193ad06cd992852eedf54ebc0e0bdce7ff7fa3f54d92e0400170b17e6b8c7c"
            }
        },
        "Ports": {},
        "SandboxID": "48eb6078bbc4947e71560486a501da8373d2990fe001effc138e06d159d8f644",
        "SandboxKey": "/var/run/docker/netns/48eb6078bbc4",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "Path": "cat",
    "Platform": "linux",
    "ProcessLabel": "",
    "ResolvConfPath": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/containers/5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535/resolv.conf",
    "RestartCount": 0,
    "State": {
        "Dead": false,
        "Error": "",
        "ExitCode": 0,
        "FinishedAt": "2021-08-11T08:51:48.123943658Z",
        "OOMKilled": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": false,
        "Running": false,
        "StartedAt": "2021-08-11T08:51:48.097573826Z",
        "Status": "exited"
    }
}

Fetch the logs

GET /api/v1/container/(string: container_type)/(string: container_id)/logs

Fetch the logs of a container. Support Docker container only.

Query Parameters:
 
  • tail – (optional) Output the specified number of lines at the end of logs. Default is 100.
Response JSON Object:
 
  • logs (string) – logs string
  • tail (int) – the last N line of output

Example request of LXD

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/<container_id>/logs

Example response of LXD

"Detected architecture x86-64.\r\n\r\nWelcome to Ubuntu 18.04.5 LTS!\r\n\r\nSet hostname to <lxdTest>.\r\nInitializing machine ID from random generator.\r\nFailed to read AF_UNIX datagram queue length, ignoring: No such file or directory\r\nFailed to install release agent, ignoring: No such file or directory\r\nFile /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.\r\nProceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)\r\n/run/systemd/system/systemd-udev-trigger.service.d/zzz-lxc-override.conf:3: Executable path is not absolute, ignoring: -udevadm trigger --type=subsystems --action=add\r\n/run/systemd/system/systemd-udev-trigger.service.d/zzz-lxc-override.conf:4: Executable path is not absolute, ignoring: -udevadm trigger --type=devices --action=add\r\nsystemd-udev-trigger.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.\r\nsystemd-udev-trigger.service: Cannot add dependency job, ignoring: Unit systemd-udev-trigger.service is not loaded properly: Invalid argument.\r\n[  OK  ] Reached target Remote File Systems.\r\n[  OK  ] Started Forward Password Requests to Wall Directory Watch.\r\n[  OK  ] Reached target Swap.\r\nsystem.slice: Failed to reset devices.list: Operation not permitted\r\n[  OK  ] Created slice System Slice.\r\n[  OK  ] Listening on udev Kernel Socket.\r\n[  OK  ] Listening on udev Control Socket.\r\n[  OK  ] Listening on Network Service Netlink Socket.\r\n[  OK  ] Listening on Syslog Socket.\r\n[  OK  ] Listening on Journal Socket.\r\ndev-mqueue.mount: Failed to reset devices.list: Operation not permitted\r\n         Mounting POSIX Message Queue File System...\r\nsystemd-sysctl.service: Failed to reset devices.list: Operation not permitted\r\n         Starting Apply Kernel Variables...\r\n[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.\r\nsystemd-tmpfiles-setup-dev.service: Failed to reset devices.list: Operation not permitted\r\n         Starting Create Static Device Nodes in /dev...\r\n[UNSUPP] Starting of Arbitrary Executable Fi\u2026tem Automount Point not supported.\r\nuser.slice: Failed to reset devices.list: Operation not permitted\r\n[  OK  ] Created slice User and Session Slice.\r\n[  OK  ] Reached target Slices.\r\n[  OK  ] Started Dispatch Password Requests to Console Directory Watch.\r\n[  OK  ] Reached target Local Encrypted Volumes.\r\n[  OK  ] Reached target Paths.\r\n[  OK  ] Listening on Journal Socket (/dev/log).\r\nsystemd-journald.service: Failed to reset devices.list: Operation not permitted\r\n         Starting Journal Service...\r\nkeyboard-setup.service: Failed to reset devices.list: Operation not permitted\r\n         Starting Set the console keyboard layout...\r\n[  OK  ] Started Apply Kernel Variables.\r\n[  OK  ] Mounted POSIX Message Queue File System.\r\n[  OK  ] Started Create Static Device Nodes in /dev.\r\nsystemd-udevd.service: Failed to reset devices.list: Operation not permitted\r\n         Starting udev Kernel Device Manager...\r\n[  OK  ] Started Journal Service.\r\n         Starting Flush Journal to Persistent Storage...\r\n[  OK  ] Started udev Kernel Device Manager.\r\n         Starting Network Service...\r\n[  OK  ] Started Set the console keyboard layout.\r\n[  OK  ] Reached target Local File Systems (Pre).\r\n[  OK  ] Reached target Local File Systems.\r\n         Starting Set console font and keymap...\r\n[  OK  ] Started Set console font and keymap.\r\n[  OK  ] Started Network Service.\r\n[  OK  ] Started Flush Journal to Persistent Storage.\r\n         Starting Create Volatile Files and Directories...\r\n[  OK  ] Started Create Volatile Files and Directories.\r\n[  OK  ] Reached target System Time Synchronized.\r\n         Starting Update UTMP about System Boot/Shutdown...\r\n         Starting Network Name Resolution...\r\n[  OK  ] Started Update UTMP about System Boot/Shutdown.\r\n[  OK  ] Reached target System Initialization.\r\n[  OK  ] Started Daily apt download activities.\r\n[  OK  ] Listening on D-Bus System Message Bus Socket.\r\n[  OK  ] Reached target Sockets.\r\n[  OK  ] Reached target Basic System.\r\n         Starting Dispatcher daemon for systemd-networkd...\r\n         Starting Login Service...\r\n[FAILED] Failed to start Ubuntu Advantage update messaging.\r\nSee 'systemctl status ua-messaging.timer' for details.\r\n[  OK  ] Started Daily Cleanup of Temporary Directories.\r\n[  OK  ] Started Regular background program processing daemon.\r\n[  OK  ] Started Daily apt upgrade and clean activities.\r\n         Starting System Logging Service...\r\n[  OK  ] Started Message of the Day.\r\n[  OK  ] Started D-Bus System Message Bus.\r\n[  OK  ] Reached target Timers.\r\n[  OK  ] Started Network Name Resolution.\r\n[  OK  ] Reached target Network.\r\n         Starting Permit User Sessions...\r\n[  OK  ] Reached target Host and Network Name Lookups.\r\n[  OK  ] Started System Logging Service.\r\n[  OK  ] Started Login Service.\r\n[  OK  ] Started Permit User Sessions.\r\n[  OK  ] Created slice system-getty.slice.\r\n[  OK  ] Started Console Getty.\r\n[  OK  ] Reached target Login Prompts.\r\n[  OK  ] Started Dispatcher daemon for systemd-networkd.\r\n[  OK  ] Reached target Multi-User System.\r\n[  OK  ] Reached target Graphical Interface.\r\n         Starting Update UTMP about System Runlevel Changes...\r\n[  OK  ] Started Update UTMP about System Runlevel Changes.\r\n\r\r\nUbuntu 18.04.5 LTS lxdTest console\r\n\r\nlxdTest login: "

Example request of Docker

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/logs

Example response of Docker

{
    "logs": "root:x:0:0:root:/root:/bin/bash\r\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\r\nbin:x:2:2:bin:/bin:/usr/sbin/nologin\r\nsys:x:3:3:sys:/dev:/usr/sbin/nologin\r\nsync:x:4:65534:sync:/bin:/bin/sync\r\ngames:x:5:60:games:/usr/games:/usr/sbin/nologin\r\nman:x:6:12:man:/var/cache/man:/usr/sbin/nologin\r\nlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin\r\nmail:x:8:8:mail:/var/mail:/usr/sbin/nologin\r\nnews:x:9:9:news:/var/spool/news:/usr/sbin/nologin\r\nuucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin\r\nproxy:x:13:13:proxy:/bin:/usr/sbin/nologin\r\nwww-data:x:33:33:www-data:/var/www:/usr/sbin/nologin\r\nbackup:x:34:34:backup:/var/backups:/usr/sbin/nologin\r\nlist:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin\r\nirc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin\r\ngnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin\r\nnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin\r\n_apt:x:100:65534::/nonexistent:/usr/sbin/nologin\r\n",
    "tail": 100
}

Start a container

PUT /api/v1/container/(string: container_type)/(string: container_id)/start

Start a container.

Return the last status by GET /api/v1/container/(string:container_type)/(string:container_id)

Example request of LXC

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/start

Example response of LXC

{
    "cpu": 0.0,
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "ipaddress": [],
    "memory": 0,
    "name": "utest",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 0,
    "type": "lxc"
}

Example request of LXD

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/lxdTest/start

Example response of LXD

{
    "cpu": 0.0,
    "id": "lxdTest",
    "image": "ubuntu:bionic",
    "imageID": "3b0756c739364ef5d05b18c0675eefcba7235f74062a3947a3d0b6c34416202f",
    "ipaddress": [
        "10.0.7.3"
    ],
    "memory": 27881472,
    "name": "lxdTest",
    "rx": 1937,
    "state": "running",
    "tcpPort": [],
    "tx": 194,
    "type": "lxd"
}

Example request of Docker

$ curl -sq -XPUT -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/start

Example response of Docker

{
    "cpu": 0.0,
    "externalIP": "",
    "id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
    "image": "ubuntu:latest",
    "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
    "ipaddress": [],
    "memory": 0,
    "name": "DockerTestAPI",
    "networkMode": "",
    "project": "",
    "projectPath": "",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 0,
    "type": "docker"
}

Restart a container

PUT /api/v1/container/(string: container_type)/(string: container_id)/restart

Restart a container.

Return the last status by GET /api/v1/container/(string:container_type)/(string:container_id)

Example request of LXC

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/restart

Example response of LXC

{
    "cpu": 0.0,
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "ipaddress": [],
    "memory": 0,
    "name": "utest",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 0,
    "type": "lxc"
}

Example request of LXD

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/lxdTest/restart

Example response of LXD

{
    "id": "lxdTest",
    "image": "ubuntu:bionic",
    "imageID": "3b0756c739364ef5d05b18c0675eefcba7235f74062a3947a3d0b6c34416202f",
    "ipaddress": [],
    "name": "lxdTest",
    "state": "stopped",
    "tcpPort": [],
    "type": "lxd"
}

Example request of Docker

$ curl -sq -XPUT -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/restart

Example response of Docker

{
    "cpu": 0.0,
    "externalIP": "",
    "id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
    "image": "ubuntu:latest",
    "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
    "ipaddress": [],
    "memory": 0,
    "name": "DockerTestAPI",
    "networkMode": "",
    "project": "",
    "projectPath": "",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 0,
    "type": "docker"
}

Basic information

GET /api/v1/container/(string: container_type)/(string: container_id)
Parameters:
  • container_typelxc, lxd, docker
  • container_id – container id
Response JSON Object:
 
  • id (string) – container ID
  • name (string) – container name
  • image (string) – derived from
  • state (string) – one of running, stopped
  • type (string) – one of lxc, lxd, docker
  • cpu (float) – cpu usage
  • memory (int) – memory usage
  • rx (int) – network receive rate
  • tx (int) – network transmit rate
  • ipaddress (array) – container IP address
  • tcpPort (array) – Host TCP port forward number

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest

Example response

{
    "cpu": 0.1300556586270872,
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "ipaddress": [
        "10.0.3.240"
    ],
    "memory": 27705344,
    "name": "utest",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 250,
    "type": "lxc"
}

Stop a container

PUT /api/v1/container/(string: container_type)/(string: container_id)/stop

Stop a running container.

Return the last status by GET /api/v1/container/(string:container_type)/(string:container_id)

Example request of LXC

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/utest/stop

Example response of LXC

{
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "name": "utest",
    "state": "stopped",
    "tcpPort": [],
    "type": "lxc"
}

Example request of LXD

$ curl -sq -XPUT -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/lxdTest/stop

Example response of LXD

{
    "cpu": 0.0004997334754797442,
    "id": "lxdTest",
    "image": "ubuntu:bionic",
    "imageID": "3b0756c739364ef5d05b18c0675eefcba7235f74062a3947a3d0b6c34416202f",
    "ipaddress": [
        "10.0.7.3"
    ],
    "memory": 19111936,
    "name": "lxdTest",
    "rx": 0,
    "state": "running",
    "tcpPort": [],
    "tx": 0,
    "type": "lxd"
}

Example request of Docker

$ curl -sq -XPUT -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/stop

Example response of Docker

{
    "externalIP": "",
    "id": "5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535",
    "image": "ubuntu:latest",
    "imageID": "sha256:1318b700e415001198d1bf66d260b07f67ca8a552b61b0da02b3832c778f221b",
    "name": "DockerTestAPI",
    "networkMode": "",
    "project": "",
    "projectPath": "",
    "state": "stopped",
    "tcpPort": [],
    "type": "docker"
}

Remove a container

DELETE /api/v1/container/(string: container_type)/(string: container_id)

Remove a container. Return {} if success

Example request of LXC

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxc/<container_id>

Example response of LXC

{}

Example request of LXD

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/container/lxd/<container_id>

Example response of LXD

{}

Example request of Docker

Query Parameters:
 
  • remove_volumes – Automatically remove anonymous volumes associated with the container. Default is false.
$ curl -sq -XDELETE -b cookies.txt \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>

Example response of Docker

{}

Commit container

POST /api/v1/container/docker/(string: container_id)/commit

Create a new container.

Request JSON Object:
 
  • repository (string) – image name
  • tag (string) – image tag
  • author (string) – author
  • message (string) – commit message

Example request of Docker

$ curl -sq -X POST -b cookies.txt -d '{"repository":"aaa","tag":"v1","author":"jj","message":"hi"}' \
    http://${QIP}:${QPORT}/container-station/api/v1/container/docker/<container_id>/commit

Example response of Docker

{
    "image_id": "sha256:589150dad6c0c8dcfe2e9d69ae45b6b88fe6255e1de2ca08fdbdf78f29819c10"
}