mirror of https://github.com/docker/docs.git
commit
81b01b44c6
|
@ -25,7 +25,7 @@ func (r ContainerDecoder) DecodeHostConfig(src io.Reader) (*container.HostConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper
|
// DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper
|
||||||
// struct and returns both a Config and an HostConfig struct
|
// struct and returns both a Config and a HostConfig struct
|
||||||
// Be aware this function is not checking whether the resulted structs are nil,
|
// Be aware this function is not checking whether the resulted structs are nil,
|
||||||
// it's your business to do so
|
// it's your business to do so
|
||||||
func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) {
|
func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ func doesEnvExist(name string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateExtraHost validates that the specified string is a valid extrahost and returns it.
|
// ValidateExtraHost validates that the specified string is a valid extrahost and returns it.
|
||||||
// ExtraHost are in the form of name:ip where the ip has to be a valid ip (ipv4 or ipv6).
|
// ExtraHost is in the form of name:ip where the ip has to be a valid ip (ipv4 or ipv6).
|
||||||
func ValidateExtraHost(val string) (string, error) {
|
func ValidateExtraHost(val string) (string, error) {
|
||||||
// allow for IPv6 addresses in extra hosts by only splitting on first ":"
|
// allow for IPv6 addresses in extra hosts by only splitting on first ":"
|
||||||
arr := strings.SplitN(val, ":", 2)
|
arr := strings.SplitN(val, ":", 2)
|
||||||
|
|
|
@ -150,7 +150,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
|
||||||
if *flStdin {
|
if *flStdin {
|
||||||
attachStdin = true
|
attachStdin = true
|
||||||
}
|
}
|
||||||
// If -a is not set attach to the output stdio
|
// If -a is not set, attach to stdout and stderr
|
||||||
if flAttach.Len() == 0 {
|
if flAttach.Len() == 0 {
|
||||||
attachStdout = true
|
attachStdout = true
|
||||||
attachStderr = true
|
attachStderr = true
|
||||||
|
@ -246,7 +246,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
|
||||||
// Validate if the given hostname is RFC 1123 (https://tools.ietf.org/html/rfc1123) compliant.
|
// Validate if the given hostname is RFC 1123 (https://tools.ietf.org/html/rfc1123) compliant.
|
||||||
hostname := *flHostname
|
hostname := *flHostname
|
||||||
if hostname != "" {
|
if hostname != "" {
|
||||||
// Linux hostname is limited to HOST_NAME_MAX=64, not not including the terminating null byte.
|
// Linux hostname is limited to HOST_NAME_MAX=64, not including the terminating null byte.
|
||||||
matched, _ := regexp.MatchString("^(([[:alnum:]]|[[:alnum:]][[:alnum:]\\-]*[[:alnum:]])\\.)*([[:alnum:]]|[[:alnum:]][[:alnum:]\\-]*[[:alnum:]])$", hostname)
|
matched, _ := regexp.MatchString("^(([[:alnum:]]|[[:alnum:]][[:alnum:]\\-]*[[:alnum:]])\\.)*([[:alnum:]]|[[:alnum:]][[:alnum:]\\-]*[[:alnum:]])$", hostname)
|
||||||
if len(hostname) > 64 || !matched {
|
if len(hostname) > 64 || !matched {
|
||||||
return nil, nil, nil, cmd, fmt.Errorf("invalid hostname format for --hostname: %s", hostname)
|
return nil, nil, nil, cmd, fmt.Errorf("invalid hostname format for --hostname: %s", hostname)
|
||||||
|
@ -473,7 +473,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
|
||||||
return config, hostConfig, networkingConfig, cmd, nil
|
return config, hostConfig, networkingConfig, cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads a file of line terminated key=value pairs and override that with override parameter
|
// reads a file of line terminated key=value pairs, and overrides any keys
|
||||||
|
// present in the file with additional pairs specified in the override parameter
|
||||||
func readKVStrings(files []string, override []string) ([]string, error) {
|
func readKVStrings(files []string, override []string) ([]string, error) {
|
||||||
envVariables := []string{}
|
envVariables := []string{}
|
||||||
for _, ef := range files {
|
for _, ef := range files {
|
||||||
|
@ -539,7 +540,7 @@ func parseSecurityOpts(securityOpts []string) ([]string, error) {
|
||||||
return securityOpts, nil
|
return securityOpts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse storage options per container into a map
|
// parses storage options per container into a map
|
||||||
func parseStorageOpts(storageOpts []string) (map[string]string, error) {
|
func parseStorageOpts(storageOpts []string) (map[string]string, error) {
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
for _, option := range storageOpts {
|
for _, option := range storageOpts {
|
||||||
|
@ -640,7 +641,7 @@ func ParseLink(val string) (string, string, error) {
|
||||||
if len(arr) == 1 {
|
if len(arr) == 1 {
|
||||||
return val, val, nil
|
return val, val, nil
|
||||||
}
|
}
|
||||||
// This is kept because we can actually get an HostConfig with links
|
// This is kept because we can actually get a HostConfig with links
|
||||||
// from an already created container and the format is not `foo:bar`
|
// from an already created container and the format is not `foo:bar`
|
||||||
// but `/foo:/c1/bar`
|
// but `/foo:/c1/bar`
|
||||||
if strings.HasPrefix(arr[0], "/") {
|
if strings.HasPrefix(arr[0], "/") {
|
||||||
|
|
Loading…
Reference in New Issue