@@ -1,13 +1,71 @@
11{-# LANGUAGE ExplicitForAll #-}
22{-# LANGUAGE ScopedTypeVariables #-}
33
4+{-|
5+Module : Docker.Client
6+Copyright : (c) Deni Bertovic, 2016
7+License : BSD3
8+Maintainer : deni@denibertovic.com
9+Stability : experimental
10+Portability : POSIX
11+
12+Getting started
13+
14+* Creating a container:
15+
16+We're going to create a nginx container and we're going to map port @80@ from within the container to port @8000@ on
17+the host.
18+
19+@
20+import Docker.Client
21+
22+runNginxContainer :: IO ContainerID
23+runNginxContainer = runDockerT (defaultClientOpts, defaultHttpHandler) $ do
24+ let pb = PortBinding 80 TCP [HostPort "0.0.0.0" 8000]
25+ let myCreateOpts = addPortBinding (defaultCreateOpts "nginx:latest") pb
26+ cid <- createContainer myCreateOpts
27+ case cid of
28+ Left err -> error $ show err
29+ Right i -> do
30+ _ <- startContainer defaultStartOpts i
31+ return i
32+@
33+
34+Let's start out nginx container:
35+
36+>>> cid <- runNginxContainer
37+
38+
39+Visit http://localhost:8000 and verify that nginx is running.
40+
41+Let's stop the container now:
42+
43+@
44+stopNginxContainer :: ContainerID -> IO ()
45+stopNginxContainer cid = runDockerT (defaultClientOpts, defaultHttpHandler) $ do
46+ r <- stopContainer DefaultTimeout cid
47+ case r of
48+ Left err -> error "I failed to stop the container"
49+ Right _ -> return ()
50+@
51+
52+>>> stopNginxContainer cid
53+
54+* Get Docker API Version:
55+
56+>>> runDockerT (defaultClientOpts, defaultHttpHandler) $ getDockerVersion
57+Right (DockerVersion {version = "1.12.0", apiVersion = "1.24", gitCommit = "8eab29e", goVersion = "go1.6.3", os = "linux", arch = "amd64", kernelVersion = "4.6.0-1-amd64", buildTime = "2016-07-28T21:46:40.664812891+00:00"})
58+
59+-}
460module Docker.Client (
61+ -- * Client functions
562 module Docker.Client.Api
63+ -- * Types
664 , module Docker.Client.Types
65+ -- * Http
766 , module Docker.Client.Http
867 ) where
968
1069import Docker.Client.Api
1170import Docker.Client.Http
1271import Docker.Client.Types
13−