Skip to content

Commit

Permalink
Set the hostname for containers and functions
Browse files Browse the repository at this point in the history
By setting the hostname, the container will resolve to its
name instead of just localhost.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Feb 21, 2021
1 parent 27ba86f commit 6c0f91e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/provider/handlers/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func deploy(ctx context.Context, req types.FunctionDeployment, client *container
containerd.WithSnapshotter(snapshotter),
containerd.WithNewSnapshot(name+"-snapshot", image),
containerd.WithNewSpec(oci.WithImageConfig(image),
oci.WithHostname(name),
oci.WithCapabilities([]string{"CAP_NET_RAW"}),
oci.WithMounts(mounts),
oci.WithEnv(envs),
Expand Down
1 change: 1 addition & 0 deletions pkg/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func (s *Supervisor) Start(svcs []Service) error {
containerd.WithImage(image),
containerd.WithNewSnapshot(svc.Name+"-snapshot", image),
containerd.WithNewSpec(oci.WithImageConfig(image),
oci.WithHostname(svc.Name),
withUserOrDefault(svc.User),
oci.WithCapabilities(svc.Caps),
oci.WithMounts(mounts),
Expand Down

0 comments on commit 6c0f91e

Please sign in to comment.