Skip to content

Instantly share code, notes, and snippets.

@jschneiderhan
Last active August 29, 2015 14:08
Show Gist options
  • Save jschneiderhan/42aaba7ec8327f204d2d to your computer and use it in GitHub Desktop.
Save jschneiderhan/42aaba7ec8327f204d2d to your computer and use it in GitHub Desktop.
Shipyard: How do you use '&' in environment variable values?
$ cat add-container.json
{
"name": "flynn/slugrunner",
"cpus": 0.1,
"memory": 256,
"type": "service",
"hostname": "",
"domain": "",
"labels": ["sample-web"],
"args": [],
"environment": {
"SLUG_URL": "https://example.com/slugs?key1=val1&key2=val2"
},
"restart_policy": {
"name": "always"
},
"bind_ports": [
{
"host_ip": "10.1.2.3",
"proto": "tcp",
"container_port": 8080
},
{
"proto": "tcp",
"port": 80,
"container_port": 8080
}
],
"links": {
}
}
$ curl -XPOST -H 'Content-Type: application/json' \
-H 'X-Service-Key: REDACTED' \
-H 'Accept: application/json' \
--data @add-container.json \
http://localhost:8080/api/containers
[{"id":"a814121e6426326c065f5ddcdb4e4f78c083de9c596659f8a7e281d497902655","image":{"name":"flynn/slugrunner","cpus":0.1,"memory":256,"environment":{"SLUG_URL":"https://example.com/slugs?key1=val1\u0026key2=val2"},"type":"service","labels":["sample-web"],"bind_ports":[{"proto":"tcp","host_ip":"10.1.2.3","container_port":8080},{"proto":"tcp","port":80,"container_port":8080}],"restart_policy":{"name":"always"}},"engine":{"id":"host1","addr":"http://172.17.42.1:2375","cpus":1,"memory":1024,"labels":["sample-web"]},"ports":[{"proto":"tcp","host_ip":"0.0.0.0","port":80,"container_port":8080}]}]
@jschneiderhan
Copy link
Author

The value for SLUG_URL changes from https://example.com/slugs?key1=val1&key2=val2 to https://example.com/slugs?key1=val1\u0026key2=val2. The version with the \u0026 encoded ampersand is what ends up being passed to docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment