Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Add a curl example showing how to set container environment variables with the REST API #256

@wallrj

Description

@wallrj

Even if we just added something similar to the curl command below to the README file.

  • Dockerfile
FROM busybox
MAINTAINER ClusterHQ <support@clusterhq.com>
CMD ["/bin/sh",  "-c", "env"]
$ docker build --tag="clusterhq/env" .
Sending build context to Docker daemon 9.728 kB
Sending build context to Docker daemon 
Step 0 : FROM busybox
 ---> a9eb17255234
Step 1 : MAINTAINER ClusterHQ <support@clusterhq.com>
 ---> Using cache
 ---> 02882f3e8884
Step 2 : CMD ["/bin/sh",  "-c", "env"]
 ---> Running in 80d71a6e0cdf
 ---> 49b7d02ae8fd
Removing intermediate container 80d71a6e0cdf
Successfully built 49b7d02ae8fd
FROM busybox
MAINTAINER ClusterHQ <support@clusterhq.com>
CMD ["/bin/sh",  "-c", "env"]
  • Create a unit
$ curl --request PUT --header "Content-Type: application/json" --data '{"Image": "clusterhq/env:latest", "Started":true, "Environment":{"Id":"env-printer-environment", "Variables":[{"Name": "Foo", "Value": "Bar"}]}}' "http://localhost:43273/container/env-printer"
$ sudo gear status env-printer
...
Aug 14 06:19:43 localhost.localdomain docker[10897]: HOSTNAME=2804db9260c1
Aug 14 06:19:43 localhost.localdomain docker[10897]: SHLVL=1
Aug 14 06:19:43 localhost.localdomain docker[10897]: HOME=/
Aug 14 06:19:43 localhost.localdomain docker[10897]: Foo=Bar
Aug 14 06:19:43 localhost.localdomain docker[10897]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • Retrieving the environment with REST doesn't seem to work though.
$ curl "http://localhost:43273/environment/env-printer-environment"

...perhaps gear doesn't yet know how to format environment as JSON???

  • gear command line client returns the expected output
$ sudo gear env env-printer-environment
Foo=Bar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions