mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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
1 changed files with 71 additions and 21 deletions
|
@ -8,7 +8,7 @@ Windows PowerShell Desired State Configuration (DSC) is a configuration
|
|||
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
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
only an Ubuntu target is supported. The Ubuntu target must already have the
|
||||
required OMI Server and PowerShell DSC for Linux providers installed. More
|
||||
information can be found at https://github.com/MSFTOSSMgmt/WPSDSCLinux. The
|
||||
source repository listed below also includes PowerShell DSC for Linux
|
||||
information can be found at [https://github.com/MSFTOSSMgmt/WPSDSCLinux](https://github.com/MSFTOSSMgmt/WPSDSCLinux).
|
||||
The source repository listed below also includes PowerShell DSC for Linux
|
||||
installation and init scripts along with more detailed installation information.
|
||||
|
||||
## Installation
|
||||
|
||||
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
|
||||
|
||||
|
@ -37,15 +37,18 @@ be used to establish the required CIM session(s) and execute the
|
|||
`Set-DscConfiguration` cmdlet.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
apt-get install docker.io
|
||||
ln -sf /usr/bin/docker.io /usr/local/bin/docker
|
||||
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys\
|
||||
36A1D7869245C8950F966E92D8576A8BA88D21E9
|
||||
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`
|
||||
|
@ -83,35 +86,82 @@ file and execute configurations against multiple nodes as such:
|
|||
```
|
||||
|
||||
### 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`
|
||||
with the `Image` parameter:
|
||||
Using the same steps defined above, execute `DockerClient` with the `Image`
|
||||
parameter and apply the configuration:
|
||||
|
||||
```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
|
||||
DockerClient -Hostname "myhost" -Image "node","mongo"
|
||||
.\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
|
||||
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" `
|
||||
-Command 'echo "Hello World!"'
|
||||
```
|
||||
docker rm -f [containername]
|
||||
```
|
||||
|
||||
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
|
||||
$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"
|
||||
```
|
||||
|
||||
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 a new issue