From 5858d9ea442968e6dfd22bfef4349594fd5b568f Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Sat, 25 May 2024 13:50:58 -0400 Subject: [PATCH] fix: map ports as exposed ports always (#237) Signed-off-by: Chris Gianelloni --- pkgmgr/docker.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pkgmgr/docker.go b/pkgmgr/docker.go index 5201d2e..9a36472 100644 --- a/pkgmgr/docker.go +++ b/pkgmgr/docker.go @@ -174,6 +174,13 @@ func (d *DockerService) Create() error { if err != nil { return err } + + // Create a new PortSet to expose all ports + exposePorts := make(nat.PortSet) + for port := range tmpPorts { + exposePorts[port] = struct{}{} + } + // Set the desired user ID and group ID userID := os.Getuid() groupID := os.Getgid() @@ -183,12 +190,13 @@ func (d *DockerService) Create() error { resp, err := client.ContainerCreate( context.Background(), &container.Config{ - Hostname: d.ContainerName, - Image: d.Image, - Entrypoint: d.Command, - Cmd: d.Args, - Env: tmpEnv[:], - User: userAndGroup, + Hostname: d.ContainerName, + Image: d.Image, + Entrypoint: d.Command, + Cmd: d.Args, + Env: tmpEnv[:], + User: userAndGroup, + ExposedPorts: exposePorts, }, &container.HostConfig{ RestartPolicy: container.RestartPolicy{