简体   繁体   中英

How to create a Dockerfile from scratch

I am new to Docker containers. I need to create a new image from scratch.

I have a folder in desktop named "Playground." Inside that folder I have a Java specific version and OATS folder and inside the OATS folder I have an .exe to install OATS.

Requirement:

I need to create an image and convert the image to a container, and when I run the container it should install Java and the OATS application.

My Docker info:

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

My Work till now:

I have created a Dockerfile and below is the code I tried in the 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

Thanks in Advance,
Satish.

There's a few things wrong that stand out. First, according to the filenames, you appear to be trying to run a Windows binary on a Linux runtime. This won't work, the Linux kernel will not run Windows binaries.

Next, when you try to use scratch, you will not have anything on the image filesystem, it's completely empty. That includes no libraries, no shell, and no distribution package tools. Using scratch is typically done for statically linked binaries, and for OS base images that have their entire OS filesystem packaged as a tar file that gets extracted as the first step. If your jdk doesn't include all the OS libraries, shell, and other dependencies, then you'll need more than "scratch" as your base image.

If you are determined to use scratch for your base, then I'd look at a desired jdk image on the Docker hub and follow back the image tree until you get to scratch and look at all the steps needed to recreate that jdk image. You'll likely need to checkout multiple repos if you want to recreate this. And if you want to do this with Windows instead of Linux binaries, then you'll need to change your Docker host settings and look into recreating the Windows core base image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM