Tools.Windows.DockerOrchestrator 1.1.0

dotnet add package Tools.Windows.DockerOrchestrator --version 1.1.0
NuGet\Install-Package Tools.Windows.DockerOrchestrator -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tools.Windows.DockerOrchestrator" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tools.Windows.DockerOrchestrator --version 1.1.0
#r "nuget: Tools.Windows.DockerOrchestrator, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tools.Windows.DockerOrchestrator as a Cake Addin
#addin nuget:?package=Tools.Windows.DockerOrchestrator&version=1.1.0

// Install Tools.Windows.DockerOrchestrator as a Cake Tool
#tool nuget:?package=Tools.Windows.DockerOrchestrator&version=1.1.0

Windows.DockerOrchestrator

This is an orchestration API for Docker on Windows platforms. Docker has to be installed for this to function properly.

Table of Contents

  1. API
    • DockerContainerConfig
    • DockerContainer
    • DockerContainer methods
  2. Examples

API

This is an API reference for the Windows.DockerOrchestrator library.

DockerContainerConfig

Method Description
class DockerContainerConfig This is the class we will use to configure the container before creating it.

DockerContainer

Method Description
class DockerContainer(DockerContainerConfig config) This is the main class we will be making operations to.

DockerContainer methods

Method Description
bool DockerContainer.Create() Creates a new container with specified configuration. Returns wether container was created successfully or not.
bool DockerContainer.Start() Starts the container. Returns wether container was started successfully or not.
bool DockerContainer.Stop() Stops the container. Returns wether container was stopped successfully or not.
bool DockerContainer.Exists() Determines if the container exists and returns the result.
bool DockerContainer.Delete(bool force = false) Deletes the container and returns wether it was successfully deleted or not.
bool DockerContainer.CopyTo(string machinePath, string remotePath) Copies a file or folder from the local machine to the container.
bool DockerContainer.CopyFrom(string remotePath, string machinePath) Copies a file or folder from the container to the local machine.
string DockerContainer.Execute(string command) Executes a command in the container using the container's default command line.

Examples

This is an example on how to create a container, set up the .NET ecosystem and run an application as a service.

using Windows.DockerOrchestrator;

namespace Windows.DockerOrchestrator.Tests
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string containerName = "MyApp";

            DockerContainer container = new DockerContainer(new DockerContainerConfig
            {
                Name = containerName,
                OperatingSystem = "ubuntu:22.04"
            });

            container.Create();

            if(container.Exists())
            {
                Console.WriteLine("Created container! Starting...");
                container.Start();

                if(container.IsRunning())
                {
                    Console.WriteLine("Started container! Running.");

                    container.Execute("apt-get update");
                    container.Execute("apt-get install -y apt-utils");
                    container.Execute("apt-get install -y wget apt-transport-https");
                    container.Execute("wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb");
                    container.Execute("dpkg -i packages-microsoft-prod.deb");
                    container.Execute("rm packages-microsoft-prod.deb");
                    container.Execute("apt-get install -y dotnet-sdk-8.0");
                    container.Execute("apt-get install -y systemctl");

                    container.CopyTo("MyApp", "/MyApp").Log("Copied? ");
                    container.CopyTo("MyApp.service", "/etc/systemd/system/MyApp.service").Log("Copied? ");

                    container.Execute("systemctl start MyApp");
                    container.Execute("systemctl status MyApp");
                }
            }

            Console.WriteLine("Completed.");
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 91 3/22/2024
1.0.0 81 3/5/2024

Added DockerImage functionality - you can now interact with docker images.
Changed how DockerContainer is intialized and it should now be easier to use - no more DockerContainerConfig.