Features and bugfix release
This is a minor update release with some new functionality and a few bugfixes. Most noably:
-
Added
WithHostName("my custom hostname")
on the
ContainerBuilder
. -
Added SHELL and COPY on filebuilder to build a Dockerfile. Therefore it is now possible
to write e.g. this in aFileBuilder
Fd.DefineImage("mariotoffia/issue111").ReuseIfAlreadyExists() .From("microsoft/windowsservercore:1607") .Shell("powershell", "-Command", "$ErrorActionPreference = 'Stop';") .Run("powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; exit 0") .Run( "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))") .Run("choco feature enable --name=allowGlobalConfirmation") .Run("choco install python3") .Copy("Resources/Issue/111/server.py", "C:/") .ExposePorts(8000) .Command("python", "server.py") .Builder().UseContainer().UseImage("mariotoffia/issue111") .WaitForProcess("python.exe", (long) TimeSpan.FromSeconds(30).TotalMilliseconds) .Builder() .Build() .Start()
-
Added support in
TemplateString
to distinguish from http(s) URLS and filepaths when doing modifications on windows systems. -
Added
IEngineScope
to allow for using a certain docker engine within aIDisposable
clause. It will switch to the engine choosen
and switch back (if needed) to the old engine uponDispose()
. This is useful in windows environment where a set of images of both
Linux and Windows may be executed. An example:using (var scope = Fd.EngineScope(EngineScopeType.Windows)) { using(var win = Fd...) { } }
-
Fixed bug where
WaitForProcess
did not work for Windows containers. -
Altered Behaviour on
ContainerServiceRemove
where it will notStop()
the container unlessforce = true
-
Added support for
Pause
andResume
(invokeStart
again) on bothIContainerService´ and
ICompositeContainerService`
and therefore allow for a single docker container or all containers to be paused and resumed. For example:using ( var container = Fd.UseContainer() .UseImage("postgres:9.6-alpine") .ExposePort(40001, 5432) .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword") .Build() .Start()) { AreEqual(ServiceRunningState.Running, container.State); container.Pause(); AreEqual(ServiceRunningState.Paused, container.State); var config = container.GetConfiguration(true); AreEqual(ServiceRunningState.Paused, config.State.ToServiceState()); container.Start(); AreEqual(ServiceRunningState.Running, container.State); config = container.GetConfiguration(true); AreEqual(ServiceRunningState.Running, config.State.ToServiceState()); }
-
Added support for netstandard2.1 and therefore works in netcoreapp3.x
-
Added ability to keep containers and keeprunning in composite services. Earlier
those where all killed. For example keep containers (but stop) on dispose may look like thisvar file = Path.Combine(Directory.GetCurrentDirectory(), (TemplateString) "Resources/ComposeTests/WordPress/docker-compose.yml"); ICompositeService svc = null; IContainerService c1 = null; IContainerService c2 = null; try { svc = Fd .UseContainer() .UseCompose() .FromFile(file) .RemoveOrphans() .KeepContainer() .Build().Start(); c1 = svc.Containers.First(); c2 = svc.Containers.Skip(1).First(); svc.Dispose(); Assert.AreEqual(ServiceRunningState.Stopped, c1.State); Assert.AreEqual(ServiceRunningState.Stopped, c2.State); } finally { svc?.Dispose(); c1?.Remove(true); c2?.Remove(true); }