dotnet / Docker.DotNet

:whale: .NET (C#) Client Library for Docker API
https://www.nuget.org/packages/Docker.DotNet/
MIT License
2.21k stars 373 forks source link

Start/run container with -i option #224

Open marcuslindblom opened 7 years ago

marcuslindblom commented 7 years ago

I'm using the following code to create my CreateContainerParameters

Config createContainerParameters = new Config {
  Image = "911fc62f478e",
  ArgsEscaped = false,
  AttachStderr = false,
  AttachStdin = true,
  AttachStdout = true,        
  Entrypoint = new string[] { "ffprobe" },
  Cmd = new string[] {
    "-i", "pipe:0",
    "-v", "quiet",
    "-print_format", "json",
    "-select_streams", "v:0",
    "-show_entries", "stream=nb_frames"
  },
  OpenStdin = true,
  StdinOnce = true
};

I need to add the the interactive flag -i when the container runs.

I need the container command to run like this:

docker run -i --entrypoint ffprobe [COMMAND]

How can I accomplish this?

Output of dotnet --info:

.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/1.0.4

What version of Docker.DotNet?:

2.124.3
marcuslindblom commented 7 years ago

Is the correct solution to use OpenStdin in my CreateContainerParameters? Anyways, it does not seem to work? How can I see the complete command sequence including run options?

spoon252 commented 5 years ago

I'm also interested in this option since there are a lot of CreateContainerParameters but i can't find anything that would enable -i kind of behavior like docker run -i

jterry75 commented 5 years ago

This is an old repo we no longer maintain but take a look how we did it here for a sample: https://github.com/Microsoft/Docker-PowerShell/blob/0ee84f8d2a170070dc62547949a126fdcf31e071/src/Docker.PowerShell/Cmdlets/InvokeContainerImage.cs