[lxc-devel] [lxd/master] Add Unix socket example to REST API usage.

monokal on Github lxc-bot at linuxcontainers.org
Sat May 14 11:52:33 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 345 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160514/99c717b3/attachment.bin>
-------------- next part --------------
From 525b77ae674e63fe7d9cdf06e87fd3c3c08b8244 Mon Sep 17 00:00:00 2001
From: Daniel Middleton <monokal at users.noreply.github.com>
Date: Sat, 14 May 2016 12:51:36 +0100
Subject: [PATCH] Add Unix socket example to REST API usage.

Signed-off-by: Daniel Middleton d at monokal.io
---
 README.md | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 50037e2..e8d3d68 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,22 @@ After you've got LXD installed and a session with the right permissions, you
 can take your [first steps](#first-steps).
 
 ## Using the REST API
-Here's a simple example of REST API usage via cURL:
+The LXD REST API can be used locally via unauthenticated Unix socket or remotely via SSL encapsulated TCP.
+
+#### via Unix socket
+```bash
+curl --unix-socket /var/lib/lxd/unix.socket \
+    -H "Content-Type: application/json" \
+    -X POST \
+    -d @hello-ubuntu.json \
+    "https://127.0.0.1:8443/1.0/containers"
+```
+
+#### via TCP
+TCP requires some additional configuration and is not enabled by default.
+```bash
+lxc config set core.https_address "[::]:8443"
+```
 ```bash
 curl -k -L -I \
     --cert ~/.config/lxc/client.crt \
@@ -39,7 +54,8 @@ curl -k -L -I \
     -d @hello-ubuntu.json \
     "https://127.0.0.1:8443/1.0/containers"
 ```
-where `hello-ubuntu.json` could contain:
+#### JSON payload
+The `hello-ubuntu.json` file referenced above could contain something like:
 ```json
 {
     "name":"some-ubuntu",


More information about the lxc-devel mailing list