Skip to content
This repository has been 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

Open
wallrj opened this issue Aug 14, 2014 · 0 comments

Comments

@wallrj
Copy link
Contributor

wallrj commented Aug 14, 2014

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

  • Dockerfile
FROM busybox
MAINTAINER ClusterHQ <[email protected]>
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 <[email protected]>
 ---> 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 <[email protected]>
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant