A PowerShell script for Docker project management.
A PowerShell script for Docker project management.
It writes a Docker compose file, stops a running stack, removes images of the Docker project, rebuilds them, publishes them to a registry and initializes a Docker swarm on which it deploys the new stack.
This PowerShell script installs its dependencies automatically. See Requirements.psd1.
There seems to be a bug with the nuget.org v3-API where the Install-Package command does not find matching packages to install automatically. One needs to unregister the v3-API and register the v2-API to solve this error.
> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://api.nuget.org/v3/index.json
> Unregister-PackageSource nuget.org
> Register-PackageSource nuget.org https://www.nuget.org/api/v2/ -ProviderName NuGet
Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://www.nuget.org/api/v2/
Settings are read from package.json and docker-management.json files in the Docker project’s directory.
A PowerShell script for Docker project management.
Invoke-PSDockerManagement [-ProjectPath] <String> [-EnvPath <String>] [-KeepYAML] [-KeepImages] [-Offline]
[<CommonParameters>]
It writes a Docker compose file, stops a running stack, removes images of the Docker project, rebuilds them, publishes them to a registry and initializes a Docker swarm on which it deploys the new stack.
.\Invoke-PSDockerManagement.ps1 -ProjectPath "..\docker-project-root\"
The path to the Docker project.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The path to the environment variable file.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Whether to regenerate the docker “docker-compose.yml”.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Whether to rebuild the Docker image.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Whether to install dependencies.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
The script needs to be able to read certain values from configuration files.
If they are not present in a package.json file they must be contained within the docker-management.json file.
This includes:
undefinedName [required]
The project’s name.
Most probably included the package.json.
Used for the generated image’s and stack’s name.
Example:
"Name": "project"
undefinedOwner [optional]
The project’s owner.
Used for the generated image’s name and storage in a registry.
Example:
"Owner": "dargmuesli"
undefinedRegistryAddress [optional]
Information about the registry to be used.
Contains:
Example:
"RegistryAddress": {
"Name": "registry",
"Hostname": "localhost",
"Port": "5000"
}
undefinedComposeFile [required]
Information about the Docker compose file that is created on execution.
Contains:
Where Content is the JSON representation of the compose file’s YAML.
Example:
"ComposeFile": {
"Name": "docker-compose.yml",
"Content": {
"version": "3",
"services":
...
}
}
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.