diff --git a/.vscode/settings.json b/.vscode/settings.json
index 088f113..bc9583e 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,31 +1,31 @@
{
"cSpell.words": [
- "Ductus",
- "Exploaded",
- "Ipam",
- "LOCALAPPDATA",
- "Miscellanious",
- "NOPASSWD",
- "Npgsql",
- "Toffia",
"appconfig",
"archve",
"behaviour",
"compsed",
+ "dockercli",
"dont",
+ "Ductus",
"editorconfig",
+ "Exploaded",
"flaviours",
"fluentdockerdl",
"fluentdockertest",
+ "Ipam",
"kiasaki",
+ "LOCALAPPDATA",
"lxss",
"mariotoffia",
"martoffi",
+ "Miscellanious",
"mkdir",
"myimg",
"mysecretpassword",
"mytag",
"nodetest",
+ "NOPASSWD",
+ "Npgsql",
"nuget",
"particulary",
"postgres",
@@ -34,6 +34,7 @@
"proto",
"somewordpress",
"sudoer",
+ "Toffia",
"typeof",
"wdlp"
],
diff --git a/Ductus.FluentDocker/Execution/CommandCategory.cs b/Ductus.FluentDocker/Execution/CommandCategory.cs
new file mode 100644
index 0000000..746e90f
--- /dev/null
+++ b/Ductus.FluentDocker/Execution/CommandCategory.cs
@@ -0,0 +1,46 @@
+namespace Ductus.FluentDocker.Execution
+{
+ public enum CommandCategory
+ {
+ ///
+ /// Unknown commnad category.
+ ///
+ Unknown = 0,
+ ///
+ /// Container is manageing a single container approach such as create container.
+ ///
+ ///
+ /// Even though it is possible to create multiple containers, when the command is in this
+ /// category, it is assumed that the command is for a single container.
+ ///
+ Container = 1,
+ ///
+ /// Composite is when e.g. using docker compose to allow for multiple container, network etc. operation.
+ ///
+ ///
+ /// Since e.g. docker compose may handle volumes, network etc. it is not a strict container command
+ /// that is the yielded result.
+ Composite = 2,
+ ///
+ /// Network is manageing docker networking.
+ ///
+ Network = 3,
+ ///
+ /// Volume is managing docker volumes.
+ ///
+ Volume = 4,
+ ///
+ /// Information command request.
+ ///
+ Info = 5,
+ ///
+ /// Machine is the legacy docker-machine command.
+ ///
+ Machine = 6,
+ ///
+ /// Stack manages docker stack operations.
+ ///
+ Stack = 7
+ }
+
+}
\ No newline at end of file
diff --git a/Ductus.FluentDocker/Execution/CommandType.cs b/Ductus.FluentDocker/Execution/CommandType.cs
new file mode 100644
index 0000000..95e6068
--- /dev/null
+++ b/Ductus.FluentDocker/Execution/CommandType.cs
@@ -0,0 +1,20 @@
+namespace Ductus.FluentDocker.Execution
+{
+ public enum CommandType
+ {
+ ///
+ /// Unknown command type.
+ ///
+ Unknown = 0,
+ ///
+ /// Shell is a command that will use the host environment shell to
+ /// execute the command.
+ ///
+ Shell = 1,
+ ///
+ /// DockerREST will use the Docker REST API to execute the command.
+ ///
+ DockerREST = 2
+ }
+
+}
\ No newline at end of file
diff --git a/Ductus.FluentDocker/Execution/ICommand.cs b/Ductus.FluentDocker/Execution/ICommand.cs
new file mode 100644
index 0000000..8605168
--- /dev/null
+++ b/Ductus.FluentDocker/Execution/ICommand.cs
@@ -0,0 +1,17 @@
+namespace Ductus.FluentDocker.Execution
+{
+
+ public interface ICommand
+ {
+ ///
+ /// CommandType exposes the type of command.
+ ///
+ CommandType Type { get; }
+ ///
+ /// CommandCategory exposes the category of command.
+ ///
+ ///
+ CommandCategory Category { get; }
+ }
+}
+
diff --git a/Examples/.vscode/settings.json b/Examples/.vscode/settings.json
index 5402d43..65e84c0 100644
--- a/Examples/.vscode/settings.json
+++ b/Examples/.vscode/settings.json
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"Ductus",
+ "INITDB",
"mysecretpassword"
]
}
\ No newline at end of file
diff --git a/Examples/Simple/Compose/Sample.cs b/Examples/Simple/Compose/Sample.cs
new file mode 100644
index 0000000..8a64a43
--- /dev/null
+++ b/Examples/Simple/Compose/Sample.cs
@@ -0,0 +1,28 @@
+using System.IO;
+using Ductus.FluentDocker.Model.Common;
+using Ductus.FluentDocker;
+
+namespace Simple.Compose
+{
+ public class Sample
+ {
+ public static void Runner()
+ {
+
+ var file = Path.Combine(Directory.GetCurrentDirectory(), (TemplateString)"Resources", "docker-compose.yml");
+
+ using (var svc = Fd.UseContainer()
+ .UseCompose()
+ .ForceRecreate()
+ .ServiceName("test-services")
+ .FromFile(file)
+ .RemoveOrphans()
+ .ForceRecreate()
+ .Build()
+ .Start())
+ {
+
+ }
+ }
+ }
+}
diff --git a/Examples/Simple/Compose/docker-compose.yml b/Examples/Simple/Compose/docker-compose.yml
new file mode 100644
index 0000000..9a24552
--- /dev/null
+++ b/Examples/Simple/Compose/docker-compose.yml
@@ -0,0 +1,43 @@
+version: '3.4'
+
+services:
+
+ zookeeper:
+ image: confluentinc/cp-zookeeper:5.5.6
+ container_name: "zookeeper"
+ environment:
+ ZOOKEEPER_CLIENT_PORT: 2181
+ ZOOKEEPER_TICK_TIME: 2000
+ ports:
+ - 22181:2181
+
+ kafka:
+ image: confluentinc/cp-kafka:5.5.6
+ container_name: "kafka"
+ depends_on:
+ - zookeeper
+ environment:
+ KAFKA_BROKER_ID: 1
+ KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
+ KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_HOST://localhost:29092
+ KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
+ KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
+ KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
+ ports:
+ - 29092:29092
+
+ mongodb:
+ image: mongo:5.0
+ container_name: "mongodb"
+ environment:
+ MONGO_INITDB_ROOT_USERNAME: admin
+ MONGO_INITDB_ROOT_PASSWORD: MyPassw0rd_123
+ MONGO_INITDB_DATABASE: broker-messages
+ volumes:
+ - mongodata:/data/db
+ - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
+ ports:
+ - "27017:27017"
+
+volumes:
+ mongodata:
\ No newline at end of file
diff --git a/Examples/Simple/ExecuteCommandInRunningContainer.cs b/Examples/Simple/ExecuteCommandInRunningContainer.cs
new file mode 100644
index 0000000..3fe5b13
--- /dev/null
+++ b/Examples/Simple/ExecuteCommandInRunningContainer.cs
@@ -0,0 +1,42 @@
+using System;
+using Ductus.FluentDocker.Commands;
+using Ductus.FluentDocker.Builders;
+
+namespace Simple
+{
+ internal class ExecuteCommandInRunningContainer
+ {
+ internal static void Runner()
+ {
+ using (
+ var container =
+ new Builder().UseContainer()
+ .UseImage("postgres:9.6-alpine")
+ .ExposePort(5432)
+ .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword")
+ .WaitForPort("5432/tcp", 30000)
+ .Build()
+ .Start())
+ {
+
+ var config = container.GetConfiguration(true);
+
+ // Run the *echo* command inside the running container
+ var output = container.DockerHost.Execute(
+ config.Id,
+ "echo \"I'm inside the container\"",
+ container.Certificates);
+
+ if (output.Data.Contains("I'm inside the container"))
+ {
+ Console.WriteLine("The command was executed successfully");
+ }
+ else
+ {
+ Console.WriteLine("The command was not executed successfully");
+ }
+
+ }
+ }
+ }
+}
diff --git a/Examples/Simple/Program.cs b/Examples/Simple/Program.cs
index 3bdfb22..39daf23 100644
--- a/Examples/Simple/Program.cs
+++ b/Examples/Simple/Program.cs
@@ -120,6 +120,8 @@ static void Main(string[] args)
//RunSingleContainerFluentAPI();
//PerformanceSingleContainer();
//PerformanceSingleContainerFluentAPI();
+ //ExecuteCommandInRunningContainer.Runner();
+ Compose.Sample.Runner();
}
}
}
diff --git a/Examples/Simple/Simple.csproj b/Examples/Simple/Simple.csproj
index fb5ef0a..bf92a43 100644
--- a/Examples/Simple/Simple.csproj
+++ b/Examples/Simple/Simple.csproj
@@ -5,7 +5,8 @@
netcoreapp3.1
-
+
+