Home > Net >  How to describe Docker engine request with .NET Core
How to describe Docker engine request with .NET Core

Time:10-30

Docker Engine has official documentation https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerCreate

Any my attempt to create .NET structure fit to this description was failed, I received various error like "cannot unmarshal number into Go struct field ContainerConfigWrapper.ExposedPorts of type nat.PortSet"

I want to define structure like

 Public Property Hostname As String
 ...
 Public Property ExposedPorts As ???

And than using this data as parameters

 PostData = JsonConvert.SerializeObject(PostPrm)
 Dim Response = Encoding.UTF8.GetString(Request.UploadData(URL, Encoding.UTF8.GetBytes(PostData)))

But how to describe structure ExposedPorts with .NET?

CodePudding user response:

It's essentially a dictionary type with key of type string and an empty object. Here's the documentation from that page:

object or null
An object mapping ports to an empty object in the form:

{"<port>/<tcp|udp|sctp>": {}}

So in VB.NET, the ExposedPorts property would look something like:

Public Property ExposedPorts As Dictionary(Of String, Object)
  • Related