在dockerfile中运行可执行文件 [英] Running an executable in a dockerfile

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

问题描述

我是Docker的新手,正在阅读Turnbull的Docker Book。
本质上,我掌握了容器如何工作以及传输协议和虚拟化操作系统中映像如何工作的术语和过程。

I am new to Docker and am reading through The Docker Book by Turnbull. Essentially, I have a grasp of the terms and process of how containers work and how images work in Transmission Protocol and virtualized operating systems.

但是,我的dockerfile没有运行本地的可执行文件,我不知道如何将本地可执行文件添加到容器的/ bin目录中。

however, my dockerfile is not running an executable which is local, and I can not figure out how to add my local executable into my container's /bin directory.

我的目标:我想将name.exe添加到我的容器的/ bin目录中。然后我想拥有一个docker文件,

My goal: I would like to add name.exe into the /bin directory of my container. Then I would like to have a docker file that is

FROM ubuntu
MAINTAINER me@gmail.com
RUN ["name.exe", "input1", "output"]

并保存我的容器运行我的程序,并创建输出。
我的目标是让他们将我的容器放到我的仓库中,并与我编写的所有/ bin程序共享。

and have my container run my program, and create an output. My goal is to them put my container onto my repo, and share it, along with all of the /bin programs I have written.

但是,我

推荐答案

请记住 name.exe 必须与您的dockerfile位于同一目录中。 从文档中

Bear in mind that name.exe have to be in same directory as your dockerfile. From the documentation:


< src> 路径必须在构建上下文中;您不能 COPY ../something / something ,因为Docker构建的第一步是将上下文目录(和子目录)发送到Docker守护程序。

The <src> path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

那么您的dockerfile可能看起来像这样:

Your dockerfile could look like this then:

FROM ubuntu
MAINTAINER me@gmail.com
COPY name.exe /bin/
CMD ["/bin/name.exe", "input1", "output"]

然后可以像这样构建它:

You can build it then like this:

docker build --tag=me/my-image .

运行它时( docker run me / my-image ),它将运行 /bin/name.exe input1输出

And when you run it (docker run me/my-image), it will run /bin/name.exe input1 output.

这篇关于在dockerfile中运行可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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