MCPcopy Create free account
hub / github.com/docker/compose / buildContainerPortBindingOptions

Function buildContainerPortBindingOptions

pkg/compose/create.go:829–850  ·  view source on GitHub ↗
(s types.ServiceConfig)

Source from the content-addressed store, hash-verified

827}
828
829func buildContainerPortBindingOptions(s types.ServiceConfig) (network.PortMap, error) {
830 bindings := network.PortMap{}
831 for _, port := range s.Ports {
832 var err error
833 p, err := network.ParsePort(fmt.Sprintf("%d/%s", port.Target, port.Protocol))
834 if err != nil {
835 return nil, err
836 }
837 var hostIP netip.Addr
838 if port.HostIP != "" {
839 hostIP, err = netip.ParseAddr(port.HostIP)
840 if err != nil {
841 return nil, err
842 }
843 }
844 bindings[p] = append(bindings[p], network.PortBinding{
845 HostIP: hostIP,
846 HostPort: port.Published,
847 })
848 }
849 return bindings, nil
850}
851
852func getDependentServiceFromMode(mode string) string {
853 if strings.HasPrefix(

Callers 1

getCreateConfigsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected