Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicate non-fluent code snippet using Fluent API? #264

Open
DustinReagan opened this issue Jun 25, 2022 · 2 comments
Open

Replicate non-fluent code snippet using Fluent API? #264

DustinReagan opened this issue Jun 25, 2022 · 2 comments
Assignees
Milestone

Comments

@DustinReagan
Copy link

DustinReagan commented Jun 25, 2022

I'm currently unable to replicate the following non-fluent code in the Fluent API:

var id = _docker.Host.Run("mcr.microsoft.com/dotnet/sdk:6.0", new ContainerCreateParams()
         {
              Interactive = true,
              Volumes = new []{$"{appDir}:/app", $"{nugetConfigPath}:/app/nuget.config" },
              WorkingDirectory = "/app",
         }, _docker.Certificates).Data;
         var response = _docker.Host.Execute(id, "ls", _docker.Certificates);
         //var response = _docker.Host.Execute(id, "dotnet restore /p:Configuration=Release --use-lock-file", _docker.Certificates);
         _docker.Host.RemoveContainer(id);

Here's what I've tried:

var userProfileDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
        var appDir = Path.Combine(userProfileDir, "code/legacy/LEAF/modules-telephonebanking/TelephoneBanking.Service");
        var nugetConfigPath =  Path.Combine(userProfileDir, ".nuget/NuGet/NuGet.Config");
        
        using (var container =new Builder()
                   .UseContainer()
                   .UseImage("mcr.microsoft.com/dotnet/sdk:6.0")
                   .Mount(appDir,"/app", MountType.ReadWrite)
                   .Mount(nugetConfigPath, "/app/nuget.config", MountType.ReadOnly)
                   .UseWorkDir("/app")
                   .Build()
                   .Start())
        {
            var response = container.Execute("ls");
           
        }

When I try this I get error messages similar to : Error response from daemon: Container e0e92da3262235e7d970ef588910e6bb4fa04c195ea6d9757285c08837aaeed7 is not running.

I can't seem to find how to run the container in interactive mode in the Fluent API.

Finally, how do I simply run an existing Dockerfile using the Fluent API? I've looked through the examples and APIs and can't seem to find how to do this.

@mariotoffia
Copy link
Owner

mariotoffia commented Jul 1, 2022

Hi @DustinReagan and thanks for the report!

I'll add support for interactive for fluent API on my TODO list.

When it comes to use a docker file, the documentation states the below - doesn't this work?

        using (var services = new Builder()
          .DefineImage("mariotoffia/nodetest").ReuseIfAlreadyExists()
          .FromFile("/tmp/Dockerfile")
          .Build().Start())
        {
         // Container either build to reused if found in registry and started here.
        }

It can be found under Using the Fluent API

Cheers,
Mario :)

@mariotoffia mariotoffia self-assigned this Jul 1, 2022
@mariotoffia mariotoffia added this to To do in FluentDocker via automation Jul 1, 2022
@mariotoffia mariotoffia added this to the 3.0.0-RELEASE milestone Jul 1, 2022
@DustinReagan
Copy link
Author

@mariotoffia Oh, I apologize for missing that in the docs, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
FluentDocker
  
To do
Development

No branches or pull requests

2 participants