首页 \ 问答 \ 如何从远程api运行docker容器?(How to run docker container from remote api?)

如何从远程api运行docker容器?(How to run docker container from remote api?)

我使用此命令在docker中创建新的mysql容器。

docker run -p 3306:3306 --name containerName -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

我使用docker c#api( https://github.com/ahmetalpbalkan/Docker.DotNet )来连接和管理docker remote api。 但我无法弄清楚如何将该终端命令传递给远程api。


I use this command for create new mysql container in docker.

docker run -p 3306:3306 --name containerName -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

I use docker c# api (https://github.com/ahmetalpbalkan/Docker.DotNet) for connect and manage docker remote api. but i can't figure out how to pass that terminal command to remote api.


原文:https://stackoverflow.com/questions/37204179
更新时间:2022-03-07 15:03

最满意答案

// Im assuming y is a parameter along with x if not remove it .
// Im returning tuples to access both stringValue and DoubleValue
    let myClosure = { (x: Double, y:Double) -> (DoubleValue: Double, StringValue:String) in
        return (x * 2 + y,"\(x) * 2 + \(y)")
    }


let MyClosureResult = myClosure(2,8)
// to accessString Value
MyClosureResult.StringValue
// to access DoubleValue 
MyClosureResult.DoubleValue

// Im assuming y is a parameter along with x if not remove it .
// Im returning tuples to access both stringValue and DoubleValue
    let myClosure = { (x: Double, y:Double) -> (DoubleValue: Double, StringValue:String) in
        return (x * 2 + y,"\(x) * 2 + \(y)")
    }


let MyClosureResult = myClosure(2,8)
// to accessString Value
MyClosureResult.StringValue
// to access DoubleValue 
MyClosureResult.DoubleValue

相关问答

更多
  • // Im assuming y is a parameter along with x if not remove it . // Im returning tuples to access both stringValue and DoubleValue let myClosure = { (x: Double, y:Double) -> (DoubleValue: Double, StringValue:String) in return (x * 2 + y,"\(x) * ...
  • 你实际上没有关闭,因为你使用了( )而不是{ } 此外, first(where:)的闭包有类型(Dictionary.Iterator.Element) throws -> Bool 。 该参数是单个元组,它是迭代的(Key, Value)对。 试试这个,改为: let result = collection.first(where: { pair -> Bool in return pair.key.contains("mystring") }) 但是您可以进行一些简化 ...
  • 有一个SR-2552报告, @escaping不识别功能类别别名。 这就是为什么错误@escaping attribute only applies to function types 。 您可以通过在函数签名中扩展函数类型来解决问题: typealias Action = () -> () var action: Action? = { } func doStuff(stuff: String, completion: (@escaping ()->())?) { print(stuff) ...
  • 你是对的, sendTwitterRequest将在你的函数返回后返回,所以外函数没有办法返回一个imageURL。 相反,在闭包中,在单元格中获取所需的返回值并将其存储在某处(在成员变量中),然后让tableView自己更新它(例如,使用tableView.reloadData() )。 这将导致它再次获取单元格(cellForRow ...)。 将实现更改为使用存储该调用值的成员变量。 You are correct, sendTwitterRequest will return after your ...
  • 拉胡尔的解释是正确的,但是建议的答案有点不完整。 这是一个完整的解决方案: 像拉胡尔所说的那样声明doSomething属性是lazy 。 一个懒惰的存储属性是一个属性,其初始值直到第一次使用时才被计算。 换句话说,只有在运行时调用doSomething属性时,才会评估该闭包,此时self保证存在。 有关更多详细信息,请参阅Swift编程语言中的Lazy Stored Properties 。 为doSomething属性添加一个类型注释,以便编译器不必在编译时推断该类型,显然它不能这样做,因为闭包包含se ...
  • 你正在做一个编译器无法保留的承诺。 on函数可以随意调用任何类型的数据。 但是你传递的函数只接受String 。 如果on包括以下代码(直接或间接),系统应该做什么: action(1) 1不是String ,因此类型安全性将被破坏。 编译器不能让你这样做。 考虑这个问题的另一种方法是on采用F类型的函数,并且您传递的是F的超类型而不是F的子类型 。 String是Any的子类型。 但是函数参数的工作顺序相反。 (String)->Void是(Any)->Void的超类型。 所以这与将Any类型的变量传递 ...
  • UIView动画语法在Swift 3中更改为: UIView.animate(withDuration: 0.5, animations: { }, completion: { (Bool) in }) 调用greetingMessageWithDate : greetingMessageWithDate(date: Date(), message: "") { (greetingMessage: String, code: Int) in } UIView animation syntax ch ...
  • 这是一种使用Login.shared.getGuestToken()?.onSuccess { model in }?.onError{ error . in } Login.shared.getGuestToken()?.onSuccess { model in }?.onError{ error . in } : protocol ErrorProtocol { func onError(completion: (Error?) -> ()) } protocol SuccessProtoco ...
  • 如果您添加显式的return语句,代码的第二个版本将起作用: text() { s in countElements(s) return } 发生这种情况的原因是它使用隐式返回,它是单个语句闭包,所以它尝试使用countElements的返回值,它与预期的返回类型Void不匹配。 显式return修复了这一问题。 至于为什么它的行为方式不同,在前一种情况下, foo隐式返回与闭包返回类型相匹配的Void 。 更多信息: 来自单表达式闭包的隐式返回 The second version of ...
  • 简单的解决方案就是在封页内执行你在print()做的任何事情。 由于您已经对主队列(主/ GUI线程)进行了dispatch_async ,因此您可以在其中完成任何处理。 推新视图控制器,显示一些模态数据,更新当前视图控制器等。 只需确保没有多个线程修改/访问正在显示的本地/缓存数据。 特别是如果它被UITableViewDelegate / UITableViewDataSource实现使用,如果你开始变得非常糟糕或者与你的返回值不一致,这将会引发适合。 只要您可以在后台检索数据,并且唯一需要在主线程上执 ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)