Help Center> Cloud Container Instance> FAQs> Image Repository FAQs> How Do I Create a Container Image?
Updated on 2023-02-07 GMT+08:00

How Do I Create a Container Image?

This section describes how to use Dockerfile to create a container image for a simple web workload.

Context

After you create a containerized workload using an official Nginx image, the default Nginx welcome page is displayed. The following describes how to customize an image to change the default welcome message to Hello, CCI!.

Procedure

  1. Log in to the VM running the container engine as the root user.
  2. Run the following commands to create a file named Dockerfile:

    mkdir mynginx

    cd mynginx

    touch Dockerfile

  3. Run the following command to edit the Dockerfile file:

    vi Dockerfile

    File content:

    FROM nginx
    RUN echo '<h1>Hello,CCI!</h1>' > /usr/share/nginx/html/index.html

    Where:

    • FROM statement: specifies that an Nginx image is used as a base image.
    • RUN statement: indicates that the echo command is executed to display Hello, CCI!.

  4. Create a container image.

    docker build -t nginx:v3 .

  5. Run the following command to check the created image. The command output shows that the nginx image has been created with a tag of v3.

    docker images

Image Repository FAQs FAQs

more