Trying to build a docker image using golang

agolangf · · 451 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m trying to build a docker image using golang, I&#39;ve found this (<a href="https://godoc.org/github.com/moby/moby/client#Client.ImageBuild" rel="nofollow">https://godoc.org/github.com/moby/moby/client#Client.ImageBuild</a>) which is fantastic. However I&#39;m a bit confused on what the <code>buildContext</code> is supposed to be. I found this post on github: <a href="https://github.com/moby/moby/issues/27186" rel="nofollow">https://github.com/moby/moby/issues/27186</a> which uses a tar file. Is that tar the Dockerfile + all the files you want to link to the container? </p> <p>Has anyone done this before? Or know of some better documentation? Google-fu isn&#39;t working because all the results are about building docker containers for go apps :/</p> <hr/>**评论:**<br/><br/>endophage: <pre><p>Hey, docker engineer here. Can&#39;t say I&#39;ve touched this exact API but educated guess is it&#39;s a tar file of the directory you want to use when you &#34;ADD&#34;, COPY&#34; etc in the Dockerfile. </p> <p>For example, if I have the line &#34;ADD config.json /var/lib/foo/config.json&#34; the first path (the &#34;from&#34; location) is looked up in what we generally refer to as the build context. </p></pre>Idontlikecold: <pre><p>Ah ok thanks! </p></pre>bkeroack: <pre><p>Yes, it&#39;s an uncompressed tar stream of the filesystem contents at the root of the Docker build (in other words, everything that would be added in a <code>COPY .</code> Dockerfile command)</p> <p><a href="https://github.com/dollarshaveclub/furan/blob/master/lib/builder/builder.go#L384" rel="nofollow">https://github.com/dollarshaveclub/furan/blob/master/lib/builder/builder.go#L384</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

451 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传