Step 2: Customize and Push to Docker Hub
The last step used a Docker image which Microsoft publishes and maintains. Next step, create your own custom image. You should have a Docker ID, you probably created it to download Docker Desktop.
Red Hat Universal Base Images (UBIs) allow developers using Docker on Windows and Mac platforms to tap into the benefits of the large Red Hat ecosystem. This article demonstrates how to use Red Hat Universal Base Images with Docker from a non-Red Hat system, such as a Windows or Mac workstation. Sep 19, 2018 Download and install Docker for Windows (Image Credit: Russell Smith) Before you can download base images from Docker’s repository, you’ll need to sign in to Docker on the welcome screen.
In your favorite text editor create a file called Dockerfile in the same C:temp directory. No extension, just Dockerfile. Paste in this code and save the file:
This tells Docker to use the same IIS base image, and create a layer that adds in the HTML you created in the last step. Instead of manually copying a file into the container, you will create an image with your HTML already inside it. To build the image, in your terminal, type:
Two things, first replace <YourDockerID> with your Docker ID. Also notice the “.” at the end of the line. That tells Docker to build in the context of this directory. So when it looks to COPY the file to /inetpub/wwwroot it will use the file from this directory.
You can run it:
And go to http://localhost:8081 to see the page - note your original container is still running and you can see it at http://localhost:8080.
Finally push to Docker Hub:
You may be asked to login if you haven’t already. Then you can go to hub.docker.com, login and check your repositories
Finally, stop and remove the running containers:
Each unique version of a docker image is given a tag which describes it. Docker provides many different PHP images so deciphering which you want can be confusing at first, here's what you need to know.
Each image is of the form php:version-sapi-base for example php:7.3-fpm-alpine.
The version can be either a branch for example 7.3 or a specific release of a branch, such as 7.3.1.
Branch tags automatically get recompiled with the latest release from their branch and are the recommended images to use, as they will always be the most recent version whenever you pull them.
SAPI means Server API, it determines how PHP actually runs, be it as an independent server (FPM), a command line interface or an apache module. If you are installing to run a website for development or production you should be looking for fpm.
The base is what operating system image the PHP image was built upon. This is mainly down to what other applications and libraries you may need to have inside the image. For the smallest images with the least overhead, select the alpine base images.
Windows 7 Docker Image Download
Recommendations for PHP 7.3
|Web Server (FastCGI)||7.3-fpm-alpine||Recommended for running with NGINX or other FastCGI server|
|Web Server (Apache)||7.3-apache-stretch||Used when running as an Apache module|
|Command Line||7.3-cli-alpine||Useful for running tools such as composer or batch processes|