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)
This commit is contained in:
parent
c028bb239f
commit
7a5db6df99
|
@ -8,7 +8,7 @@ Windows PowerShell Desired State Configuration (DSC) is a configuration
|
||||||
management tool that extends the existing functionality of Windows PowerShell.
|
management tool that extends the existing functionality of Windows PowerShell.
|
||||||
DSC uses a declarative syntax to define the state in which a target should be
|
DSC uses a declarative syntax to define the state in which a target should be
|
||||||
configured. More information about PowerShell DSC can be found at
|
configured. More information about PowerShell DSC can be found at
|
||||||
http://technet.microsoft.com/en-us/library/dn249912.aspx.
|
[http://technet.microsoft.com/en-us/library/dn249912.aspx](http://technet.microsoft.com/en-us/library/dn249912.aspx).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ To use this guide you'll need a Windows host with PowerShell v4.0 or newer.
|
||||||
The included DSC configuration script also uses the official PPA so
|
The included DSC configuration script also uses the official PPA so
|
||||||
only an Ubuntu target is supported. The Ubuntu target must already have the
|
only an Ubuntu target is supported. The Ubuntu target must already have the
|
||||||
required OMI Server and PowerShell DSC for Linux providers installed. More
|
required OMI Server and PowerShell DSC for Linux providers installed. More
|
||||||
information can be found at https://github.com/MSFTOSSMgmt/WPSDSCLinux. The
|
information can be found at [https://github.com/MSFTOSSMgmt/WPSDSCLinux](https://github.com/MSFTOSSMgmt/WPSDSCLinux).
|
||||||
source repository listed below also includes PowerShell DSC for Linux
|
The source repository listed below also includes PowerShell DSC for Linux
|
||||||
installation and init scripts along with more detailed installation information.
|
installation and init scripts along with more detailed installation information.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
The DSC configuration example source is available in the following repository:
|
The DSC configuration example source is available in the following repository:
|
||||||
https://github.com/anweiss/DockerClientDSC. It can be cloned with:
|
[https://github.com/anweiss/DockerClientDSC](https://github.com/anweiss/DockerClientDSC). It can be cloned with:
|
||||||
|
|
||||||
$ git clone https://github.com/anweiss/DockerClientDSC.git
|
$ git clone https://github.com/anweiss/DockerClientDSC.git
|
||||||
|
|
||||||
|
@ -37,15 +37,18 @@ be used to establish the required CIM session(s) and execute the
|
||||||
`Set-DscConfiguration` cmdlet.
|
`Set-DscConfiguration` cmdlet.
|
||||||
|
|
||||||
More detailed usage information can be found at
|
More detailed usage information can be found at
|
||||||
https://github.com/anweiss/DockerClientDSC.
|
[https://github.com/anweiss/DockerClientDSC](https://github.com/anweiss/DockerClientDSC).
|
||||||
|
|
||||||
### Run Configuration
|
### Install Docker
|
||||||
The Docker installation configuration is equivalent to running:
|
The Docker installation configuration is equivalent to running:
|
||||||
|
|
||||||
```
|
```
|
||||||
apt-get install docker.io
|
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys\
|
||||||
ln -sf /usr/bin/docker.io /usr/local/bin/docker
|
36A1D7869245C8950F966E92D8576A8BA88D21E9
|
||||||
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
|
sh -c "echo deb https://get.docker.io/ubuntu docker main\
|
||||||
|
> /etc/apt/sources.list.d/docker.list"
|
||||||
|
apt-get update
|
||||||
|
apt-get install lxc-docker
|
||||||
```
|
```
|
||||||
|
|
||||||
Ensure that your current working directory is set to the `DockerClientDSC`
|
Ensure that your current working directory is set to the `DockerClientDSC`
|
||||||
|
@ -83,35 +86,82 @@ file and execute configurations against multiple nodes as such:
|
||||||
```
|
```
|
||||||
|
|
||||||
### Images
|
### Images
|
||||||
Image configuration is equivalent to running: `docker pull [image]`.
|
Image configuration is equivalent to running: `docker pull [image]` or
|
||||||
|
`docker rmi -f [IMAGE]`.
|
||||||
|
|
||||||
Using the same Run Configuration steps defined above, execute `DockerClient`
|
Using the same steps defined above, execute `DockerClient` with the `Image`
|
||||||
with the `Image` parameter:
|
parameter and apply the configuration:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
DockerClient -Hostname "myhost" -Image node
|
DockerClient -Hostname "myhost" -Image "node"
|
||||||
|
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
||||||
```
|
```
|
||||||
|
|
||||||
The configuration process can be initiated as before:
|
You can also configure the host to pull multiple images:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
DockerClient -Hostname "myhost" -Image "node","mongo"
|
||||||
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To remove images, use a hashtable as follows:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
DockerClient -Hostname "myhost" -Image @{Name="node"; Remove=$true}
|
||||||
|
.\RunDockerClientConfig.ps1 -Hostname $hostname
|
||||||
|
```
|
||||||
|
|
||||||
### Containers
|
### Containers
|
||||||
Container configuration is equivalent to running:
|
Container configuration is equivalent to running:
|
||||||
`docker run -d --name="[containername]" [image] '[command]'`.
|
|
||||||
|
|
||||||
Using the same Run Configuration steps defined above, execute `DockerClient`
|
```
|
||||||
with the `Image`, `ContainerName`, and `Command` parameters:
|
docker run -d --name="[containername]" -p '[port]' -e '[env]' --link '[link]'\
|
||||||
|
'[image]' '[command]'
|
||||||
|
```
|
||||||
|
or
|
||||||
|
|
||||||
```powershell
|
```
|
||||||
DockerClient -Hostname "myhost" -Image node -ContainerName "helloworld" `
|
docker rm -f [containername]
|
||||||
-Command 'echo "Hello World!"'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The configuration process can be initiated as before:
|
To create or remove containers, you can use the `Container` parameter with one
|
||||||
|
or more hashtables. The hashtable(s) passed to this parameter can have the
|
||||||
|
following properties:
|
||||||
|
|
||||||
|
- Name (required)
|
||||||
|
- Image (required unless Remove property is set to `$true`)
|
||||||
|
- Port
|
||||||
|
- Env
|
||||||
|
- Link
|
||||||
|
- Command
|
||||||
|
- Remove
|
||||||
|
|
||||||
|
For example, create a hashtable with the settings for your container:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
$webContainer = @{Name="web"; Image="anweiss/docker-platynem"; Port="80:80"}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, using the same steps defined above, execute
|
||||||
|
`DockerClient` with the `-Image` and `-Container` parameters:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
DockerClient -Hostname "myhost" -Image node -Container $webContainer
|
||||||
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Existing containers can also be removed as follows:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$containerToRemove = @{Name="web"; Remove=$true}
|
||||||
|
DockerClient -Hostname "myhost" -Container $containerToRemove
|
||||||
|
.\RunDockerClientConfig.ps1 -Hostname "myhost"
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is a hashtable with all of the properties that can be used to create a
|
||||||
|
container:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$containerProps = @{Name="web"; Image="node:latest"; Port="80:80"; `
|
||||||
|
Env="PORT=80"; Link="db:db"; Command="grunt"}
|
||||||
|
```
|
Loading…
Reference in New Issue