How to build a base image from scratch?

I normally create docker image by building up on an available docker base image. Can anyone tell how do I create a base image of my own?

is the following documentation sufficient for you?

I would say there are two ways to do this:

One way:
If you’re working off a git repo. You can push your application and any other files you want inside of your scratch container there along with a Dockerfile. The Dockerfile will then do a “FROM scratch” and then you would use the ADD or COPY commands to copy the application and any files from the git repo into your image. The downside of this, is that you pushing app binaries into your git repo. This will make the repo very large over time. It’s generally a bad practice to push binaries into a git repo. Even if you delete the binary, it’s still in the tree since a git repo contains the entire history (and thus, objects) of the repo.

Another way:
If you update to the newest version of Docker (17.06). You can use the multi-stage build system. In the first image you go ahead and use an ubuntu/alpine/debian/whatever base image. Use that image to compile or create any of the files you want in the scratch image. In the second build stage, do a “FROM scratch” and copy over the collateral from the first stage that you want. This is nicer than the first solution, because you don’t have to push binaries and other collateral into your git repo.

Hope that makes some sense.

Hello,

I want to create a Mac OS base image which I will use to validate XCODE. So I want to know if that is possible via scratch. Or is there anyway to build it.

I would image it is possible to do that. People use containers to test code/applications all the time. That is another solid use case for Docker containers.

Sounds like you not only want to run the application, but also build it from a scratch container? None the less, the process would be the same.

If you want to build, copy the code, compiler, and any other collateral needed. I figure the compiler that comes with XCODE is probably some command line binary that sits somewhere on your system. You’d probably have to copy that in, and figure out what are all the switches uses to get a good compile of your code going. After that, just run the resulting binary to test.

I’ve never dealt with XCODE stuff before, but I figure it must be doable. You just have to experiment and learn a little.