如何从头开始创build一个Dockerfile

我是Docker容器的新手。 我需要从头开始创build一个新的图像。

我在桌面上有一个名为“Playground”的文件夹。 在那个文件夹里面,我有一个Java特定的版本和OATS文件夹,在OATS文件夹里有一个.exe来安装OATS。

需求:

我需要创build一个图像,并将图像转换为一个容器,当我运行容器时,它应该安装Java和OATS应用程序。

我的Docker信息:

C:\Users\Satish_D1\Desktop\Playground>docker info Containers: 5 Running: 1 Paused: 0 Stopped: 4 Images: 4 Server Version: 17.06.2-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170 runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2 init version: 949e6fa Security Options: seccomp Profile: default Kernel Version: 4.9.41-moby Operating System: Alpine Linux v3.5 OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.196GiB Name: moby ID: DEB5:62EN:AUOA:MNHN:XBSI:XXXR:DRF6:YJPD:4D2Y:672Y:R6EE:DLFG Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): true File Descriptors: 22 Goroutines: 34 System Time: 2017-09-11T13:31:33.4927898Z EventsListeners: 0 Registry: https://index.docker.io/v1/ Experimental: true Insecure Registries:127.0.0.0/8 Live Restore Enabled: false 

我的工作到现在:

我已经创build了Dockerfile,下面是我在Dockerfile中尝试的代码:

  FROM scratch COPY jdk-7u79-windows-x64 COPY C:\Users\Satish_D1\Desktop\Playground\oats-win64-full-12.5.0.3.1012\setup.bat 

Image01

Image02

提前致谢,
萨蒂什。

有一些错误突出。 首先,根据文件名,您似乎试图在Linux运行时上运行Windows二进制文件。 这将不起作用,Linux内核将不会运行Windows二进制文件。

接下来,当您尝试使用scratch时,图像文件系统上没有任何东西,它完全是空的。 这包括没有库,没有shell,没有分发包工具。 使用暂存通常是为静态链接的二进制文件和操作系统的基础映像完成的,它们将整个操作系统文件系统打包为一个tar文件,并作为第一步提取出来。 如果您的jdk不包含所有的操作系​​统库,shell以及其他依赖项,那么您将需要的不仅仅是“scratch”作为基础映像。

如果您决定为您的基础使用scratch,那么我会在Docker集线器上查看所需的jdk映像,然后返回映像树,直到您重新开始并查看重新创build该jdk映像所需的所有步骤。 如果您想重新创build,您可能需要结帐多个回购。 如果你想用Windows来代替Linux二进制文件,那么你需要改变你的Docker主机设置,并重新创buildWindows核心映像。