Browse code

updated article to reflect changes in config; fixed hyperlinks #7243

Docker-DCO-1.1-Signed-off-by: Andrew Weiss <andrew.weiss@outlook.com> (github: anweiss)

Andrew Weiss authored on 2014/07/26 03:28:36
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ Windows PowerShell Desired State Configuration (DSC) is a configuration
8 8
 management tool that extends the existing functionality of Windows PowerShell.
9 9
 DSC uses a declarative syntax to define the state in which a target should be
10 10
 configured. More information about PowerShell DSC can be found at
11
-http://technet.microsoft.com/en-us/library/dn249912.aspx.
11
+[http://technet.microsoft.com/en-us/library/dn249912.aspx](http://technet.microsoft.com/en-us/library/dn249912.aspx).
12 12
 
13 13
 ## Requirements
14 14
 
... ...
@@ -17,14 +17,14 @@ To use this guide you'll need a Windows host with PowerShell v4.0 or newer.
17 17
 The included DSC configuration script also uses the official PPA so
18 18
 only an Ubuntu target is supported. The Ubuntu target must already have the
19 19
 required OMI Server and PowerShell DSC for Linux providers installed. More
20
-information can be found at https://github.com/MSFTOSSMgmt/WPSDSCLinux. The
21
-source repository listed below also includes PowerShell DSC for Linux
20
+information can be found at [https://github.com/MSFTOSSMgmt/WPSDSCLinux](https://github.com/MSFTOSSMgmt/WPSDSCLinux).
21
+The source repository listed below also includes PowerShell DSC for Linux
22 22
 installation and init scripts along with more detailed installation information.
23 23
 
24 24
 ## Installation
25 25
 
26 26
 The DSC configuration example source is available in the following repository:
27
-https://github.com/anweiss/DockerClientDSC. It can be cloned with:
27
+[https://github.com/anweiss/DockerClientDSC](https://github.com/anweiss/DockerClientDSC). It can be cloned with:
28 28
 
29 29
     $ git clone https://github.com/anweiss/DockerClientDSC.git
30 30
 
... ...
@@ -37,15 +37,18 @@ be used to establish the required CIM session(s) and execute the
37 37
 `Set-DscConfiguration` cmdlet.
38 38
 
39 39
 More detailed usage information can be found at
40
-https://github.com/anweiss/DockerClientDSC.
40
+[https://github.com/anweiss/DockerClientDSC](https://github.com/anweiss/DockerClientDSC).
41 41
 
42
-### Run Configuration
42
+### Install Docker
43 43
 The Docker installation configuration is equivalent to running:
44 44
 
45 45
 ```
46
-apt-get install docker.io
47
-ln -sf /usr/bin/docker.io /usr/local/bin/docker
48
-sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
46
+apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys\
47
+36A1D7869245C8950F966E92D8576A8BA88D21E9
48
+sh -c "echo deb https://get.docker.io/ubuntu docker main\
49
+> /etc/apt/sources.list.d/docker.list"
50
+apt-get update
51
+apt-get install lxc-docker
49 52
 ```
50 53
 
51 54
 Ensure that your current working directory is set to the `DockerClientDSC`
... ...
@@ -83,35 +86,82 @@ file and execute configurations against multiple nodes as such:
83 83
 ```
84 84
 
85 85
 ### Images
86
-Image configuration is equivalent to running: `docker pull [image]`.
86
+Image configuration is equivalent to running: `docker pull [image]` or
87
+`docker rmi -f [IMAGE]`.
87 88
 
88
-Using the same Run Configuration steps defined above, execute `DockerClient`
89
-with the `Image` parameter:
89
+Using the same steps defined above, execute `DockerClient` with the `Image`
90
+parameter and apply the configuration:
90 91
 
91 92
 ```powershell
92
-DockerClient -Hostname "myhost" -Image node
93
+DockerClient -Hostname "myhost" -Image "node"
94
+.\RunDockerClientConfig.ps1 -Hostname "myhost"
93 95
 ```
94 96
 
95
-The configuration process can be initiated as before:
97
+You can also configure the host to pull multiple images:
96 98
 
97 99
 ```powershell
100
+DockerClient -Hostname "myhost" -Image "node","mongo"
98 101
 .\RunDockerClientConfig.ps1 -Hostname "myhost"
99 102
 ```
100 103
 
104
+To remove images, use a hashtable as follows:
105
+
106
+```powershell
107
+DockerClient -Hostname "myhost" -Image @{Name="node"; Remove=$true}
108
+.\RunDockerClientConfig.ps1 -Hostname $hostname
109
+```
110
+
101 111
 ### Containers
102 112
 Container configuration is equivalent to running:
103
-`docker run -d --name="[containername]" [image] '[command]'`.
104 113
 
105
-Using the same Run Configuration steps defined above, execute `DockerClient`
106
-with the `Image`, `ContainerName`, and `Command` parameters:
114
+```
115
+docker run -d --name="[containername]" -p '[port]' -e '[env]' --link '[link]'\
116
+'[image]' '[command]'
117
+```
118
+or
119
+
120
+```
121
+docker rm -f [containername]
122
+```
123
+
124
+To create or remove containers, you can use the `Container` parameter with one
125
+or more hashtables. The hashtable(s) passed to this parameter can have the
126
+following properties:
127
+
128
+- Name (required)
129
+- Image (required unless Remove property is set to `$true`)
130
+- Port
131
+- Env
132
+- Link
133
+- Command
134
+- Remove
135
+
136
+For example, create a hashtable with the settings for your container:
137
+
138
+```powershell
139
+$webContainer = @{Name="web"; Image="anweiss/docker-platynem"; Port="80:80"}
140
+```
141
+
142
+Then, using the same steps defined above, execute
143
+`DockerClient` with the `-Image` and `-Container` parameters:
107 144
 
108 145
 ```powershell
109
-DockerClient -Hostname "myhost" -Image node -ContainerName "helloworld" `
110
--Command 'echo "Hello World!"'
146
+DockerClient -Hostname "myhost" -Image node -Container $webContainer
147
+.\RunDockerClientConfig.ps1 -Hostname "myhost"
111 148
 ```
112 149
 
113
-The configuration process can be initiated as before:
150
+Existing containers can also be removed as follows:
114 151
 
115 152
 ```powershell
153
+$containerToRemove = @{Name="web"; Remove=$true}
154
+DockerClient -Hostname "myhost" -Container $containerToRemove
116 155
 .\RunDockerClientConfig.ps1 -Hostname "myhost"
117 156
 ```
157
+
158
+Here is a hashtable with all of the properties that can be used to create a
159
+container:
160
+
161
+```powershell
162
+$containerProps = @{Name="web"; Image="node:latest"; Port="80:80"; `
163
+Env="PORT=80"; Link="db:db"; Command="grunt"}
164
+```
118 165
\ No newline at end of file