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
- Log in to the VM running the container engine as the root user.
- Run the following commands to create a file named Dockerfile:
mkdir mynginx
cd mynginx
touch Dockerfile
- 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!"
- Create a container image.
docker build -t nginx:v3
- 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
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot