- Learn OpenShift
- Denis Zuev Artemii Kropachev Aleksey Usov
- 388字
- 2021-08-13 16:03:48
Creating a custom Docker image
The Docker community has Docker images for most popular software applications. These include, for example, images for web servers (Apache, Nginx, and so on), enterprise application platforms (JBoss EAP, Tomcat), images with programming languages (Perl, PHP, Python), and so on.
In most cases, you do not need to build your own Docker images to run standard software. But if you have a business need that requires having a custom application, you probably need to create your own Docker image.
There are a number of ways to create a new docker image:
- Commit: Creating a Docker image from a running container. Docker allows you to convert a working container to a Docker image using the docker commit command. This means that image layers will be stored as a separate docker image. This approach is the easiest way to create a new image.
- Import/Export: This is similar to the first one but uses another Docker command. Running container layers will be saved to a filesystem using docker export and then the image will be recreated using docker import. We do not recommend this method for creating a new image since the first one is simpler.
- Dockerfile: Building a Docker image using a Dockerfile. Dockerfile is a plain text file that contains a number of steps sometimes called instructions. These instructions can run a particular command inside a container or copy files to a container. A user can initiate a build process using Dockerfile and the Docker daemon will run all instructions in the Dockerfile in a temporary container. Then this container is converted to a docker image. This is the most common way to create a new docker image. Building custom docker images from Dockerfile will be described in details in a later chapter.
- From scratch: Building a base Docker image. In the two previous methods, Docker images are created using Docker images, and these docker images were created from a base Docker image. You cannot modify this base image unless you create one yourself. If you want to know what is inside your image, you might want to create a base image instead. There are two ways to do so:
- Create a base image layer using the tar command.
- Use special Dockerfile instructions (from scratch). Both methods will be described in later chapters.
推薦閱讀
- Linux設備驅動開發詳解:基于最新的Linux4.0內核
- Citrix XenApp Performance Essentials
- Windows Server 2012 Hyper-V:Deploying the Hyper-V Enterprise Server Virtualization Platform
- 從零開始寫Linux內核:一書學透核心原理與實現
- 鴻蒙生態:開啟萬物互聯的智慧新時代
- Linux實戰
- 嵌入式Linux系統開發:基于Yocto Project
- 精通Linux內核開發
- 混沌工程:復雜系統韌性實現之道
- Windows Server 2012網絡操作系統企業應用案例詳解
- Ceph分布式存儲實戰
- Linux內核設計的藝術:圖解Linux操作系統架構設計與實現原理
- Fedora 12 Linux應用基礎
- 計算機應用基礎(Windows 7+Office 2016)
- VMware Horizon View Essentials