在Dockerfile中仅读取第一行 [英] Only first line being read in Dockerfile

查看:160
本文介绍了在Dockerfile中仅读取第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Docker.DotNet(Docker Rest Api的ac#包装器)在远程linux vm上构建映像,但是仅读取了Dockerfile的第一行:

I am trying to build an image on a remote linux vm using Docker.DotNet (a c# wrapper for the Docker Rest Api), but only the first line of my Dockerfile is being read:

FROM ubuntu:14.04
RUN apt-get update && apt-get install -y php5-cli

因此,仅创建了基本的Ubuntu映像,并且尚未安装php。我已经将Dockerfile中的文件结尾转换为\n(Unix)而不是\r\n(Windows),但这没有任何效果。按照我的api调用,还没有设置图像存储库名称。

Consequently, only the base Ubuntu image has been created, and php has not been installed. I have converted the file endings in my Dockerfile to \n (Unix) rather than \r\n (Windows), but this has had no effect. The image repository name is also not being set, as per my api call.

奇怪的是,如果我在Dockerfile中仅包含一行:

Strangely, if I only include one line in my Dockerfile:

FROM ubuntu:14.04

然后设置了图像存储库名称,因此看起来像是第二行中的问题导致了问题。

Then the image repository name is set, so it looks like something in the second line is causing the problem.

这是在Docker.DotNet中调用BuildImageFromDockerfileAsync的方法:

This is the method that calls BuildImageFromDockerfileAsync in Docker.DotNet:

static async Task BuildImageFromDockerfile(DockerClient client)
    {
        var parameters = new BuildImageFromDockerfileParameters
        {
            RepositoryTagName = "test-image-python",
            RemoveIntermediateContainers = false
        };

        using (var fileStream = new FileStream(@"C:\Users\Dan\Desktop\DockerProjects\helloworld-py.tar", FileMode.Open))
        {
            await client.Miscellaneous.BuildImageFromDockerfileAsync(fileStream, parameters, new CancellationToken());
        }
    }

任何帮助将不胜感激。

Any help would be appreciated.

推荐答案

连接被关闭是问题所在,因此这似乎与Docker.DotNet有关。希望我会在接下来的几周内创建一个拉取请求并解决此问题,除了BuildFromDockerfile之外,我发现该库非常有用。目前,我只是用C#来使api自己调用。 – Dan O’Leary

The connection being closed was the problem, and so this looks to be a problem with Docker.DotNet. Hopefully I'll get chance to create a pull request and fix this in the coming weeks, as apart from BuildFromDockerfile I've found the library very useful. For the time being, I'm just making the api call myself in c#. – Dan O'Leary

这篇关于在Dockerfile中仅读取第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆