grim/convey

Add network flag.
hostnames
2017-10-04, Eric Fritz
780c59d427a1
Parents 341a204137b6
Children f079407443a2
Add network flag.
--- a/REFERENCE.md Tue Oct 03 22:51:08 2017 -0500
+++ b/REFERENCE.md Wed Oct 04 15:13:49 2017 -0500
@@ -386,6 +386,7 @@
| ----------- | -------- | ---------- | ----------- |
| command | | | The command to run in the container. This is only necessary if the image does not provide a command by default. |
| detach | | false | Will run the container in the background allowing other tasks to run. The container will be cleaned up on exit. If the image has a HEALTHCHECK specified in the Dockerfile, convey will wait until it is healthy before proceeding. |
+| network | | | Will set the --network-alias argument in the docker run command. This is generally only useful to connect to service containers. |
| entrypoint | | | The entrypoint to use for the container. This is only necessary if the image does not provide one by default. |
| environment | | | A list of environment variables to set. The should be specified in a `NAME` or `NAME=VALUE` format. If no value is provided, the value of the variable from the host will be provided if it is available. |
| healthcheck | | | See the HealthCheck attributes below. |
--- a/docker/run.go Tue Oct 03 22:51:08 2017 -0500
+++ b/docker/run.go Wed Oct 04 15:13:49 2017 -0500
@@ -38,6 +38,7 @@
type Run struct {
Command string `yaml:"command"`
Detach bool `yaml:"detach"`
+ Hostname string `yaml:"hostname"`
EntryPoint string `yaml:"entrypoint"`
Environment yaml.StringOrSlice `yaml:"environment"`
Image string `yaml:"image"`
@@ -66,6 +67,7 @@
{{if .UID}} -e UID={{.UID}}{{end}}
{{if .GID}} -e GID={{.GID}}{{end}}
{{if .Detach}} -d{{end}}
+{{if .Hostname}} --network-alias {{.Hostname}}{{end}}
-v {{.WorkspacePath}}:{{.WorkspaceMount}}
-e CONVEY_WORKSPACE={{.WorkspaceMount}}
{{if .CPUShares }} --cpu-shares {{.CPUShares}}{{end}}
@@ -193,6 +195,11 @@
return err
}
+ hostname, err := environment.Mapper(r.Hostname, fullEnv)
+ if err != nil {
+ return err
+ }
+
labels, err := st.MapSlice(r.Labels, fullEnv)
if err != nil {
return err
@@ -218,6 +225,7 @@
"Command": commandArg,
"CPUShares": st.CPUShares,
"Detach": r.Detach,
+ "Hostname": hostname,
"Environment": fullEnv,
"EntryPoint": entryPoint,
"GID": user.Gid,