@@ -68,6 +68,8 @@ module Docker.Client.Types (
6868 , UTSMode(..)
6969 , HostConfig(..)
7070 , defaultHostConfig
71+ , NetworkingConfig(..)
72+ , EndpointConfig(..)
7173 , Ulimit(..)
7274 , ContainerResources(..)
7375 , defaultContainerResources
@@ -611,20 +613,45 @@ instance FromJSON Image where
611613 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
612614 parseJSON _ = fail "Failed to parse DockerImage."
613615
616+-- | Alias for Aliases.
617+type Alias = Text
618+
619+-- | EndpointsConfig is container configuration for a specific network
620+newtype EndpointConfig = EndpointConfig [Alias] deriving (Eq, Show)
621+
622+instance ToJSON EndpointConfig where
623+ toJSON (EndpointConfig aliases) = JSON.object
624+ [ "Aliases" .= aliases
625+ ]
626+
627+-- | Data type for the NetworkingConfig section of the container settings
628+newtype NetworkingConfig = NetworkingConfig
629+ { endpointsConfig :: HM.HashMap Text EndpointConfig
630+ } deriving (Eq, Show)
631+
632+instance ToJSON NetworkingConfig where
633+ toJSON (NetworkingConfig endpointsConfig) = JSON.object
634+ [ "EndpointsConfig" .= endpointsConfig
635+ ]
614636
615637-- | Options used for creating a Container.
616638data CreateOpts = CreateOpts {
617639 containerConfig :: ContainerConfig
618640 , hostConfig :: HostConfig
641+ , networkingConfig :: Maybe NetworkingConfig
619642 } deriving (Eq, Show)
620643
621644instance ToJSON CreateOpts where
622− toJSON (CreateOpts cc hc) = do
645+ toJSON (CreateOpts cc hc nc) = do
623646 let ccJSON = toJSON cc
624647 let hcJSON = toJSON hc
625648 case ccJSON of
626649 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
627− JSON.Object $ HM.insert "HostConfig" hcJSON o
650+ let o1 = HM.insert "HostConfig" hcJSON o
651+ let o2 = case nc of
652+ Nothing -> o1
653+ Just _ -> HM.insert "NetworkingConfig" (toJSON nc) o1
654+ JSON.Object o2
628655 _ -> error "ContainerConfig is not an object." -- This should never happen.
629656
630657-- | Container configuration used for creating a container with sensible
@@ -706,7 +733,11 @@ defaultContainerResources = ContainerResources {
706733-- | Default create options when creating a container. You only need to
707734-- specify an image name and the rest is all sensible defaults.
708735defaultCreateOpts :: T.Text -> CreateOpts
709−defaultCreateOpts imageName = CreateOpts { containerConfig = defaultContainerConfig imageName, hostConfig = defaultHostConfig }
736+defaultCreateOpts imageName = CreateOpts
737+ { containerConfig = defaultContainerConfig imageName
738+ , hostConfig = defaultHostConfig
739+ , networkingConfig = Nothing
740+ }
710741
711742-- | Override the key sequence for detaching a container.
712743-- Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.