Creating a JDK8 Base Image and Pushing It to SWR
Scenarios
A base image can be used as a basis to create other images. This section describes how to create a JDK8 base image on a CCE node and push it to SWR.
Procedure
- Buy a CCE cluster.
- Log in to the CCE console.
- On the CCE cluster purchase page, configure parameters.
- Wait until the cluster is created. The new cluster will be displayed in the cluster list. The cluster status is running and the number of nodes is 0.
- Create a CCE node.
After a cluster is created, you need to create nodes for running workloads in the cluster. Assume that the node you are creating has Linux and Docker installed. You can use it to create a base image.
In the following steps, CentOS 7.6 is used as an example to describe how to create a JDK8 base image and push it to SWR.
- Log in to the CCE console.
- Click the cluster created in 1.
- In the navigation pane, choose Nodes. On the Nodes tab, click Create Node in the upper right corner. In the displayed dialog box, configure node parameters.
- For network settings, select Auto create for EIP. Set the bandwidth to 5 Mbit/s.
- Click Next: Confirm.
- Check the node specifications, read the instructions, select I have read and agree to CCE Disclaimer, and click Submit.
Wait until the node is created. The new node will be displayed in the node list. The node status is Running.
- Download a JDK package.
- After a node is created, click the node name to go to its details page.
- In the upper right corner, click Remote Login.
- Select a login mode and click Log In.
- Log in to the node as root.
- Create a directory image.
mkdir image
- Go to the image directory.
cd image
- Download a JDK package.
wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/8u352-b08/openlogic-openjdk-8u352-b08-linux-x64.tar.gz
- Build an image.
- Run vi dockerfile to write a Dockerfile as follows:
FROM centos # Use CentOS as the base image. RUN useradd -d /home/springboot -m springboot # Create a user in the working directory. ADD ./openlogic-openjdk-8u352-b08-linux-x64.tar.gz /home/springboot # Add the JDK software package to the image and decompress it automatically. RUN chown springboot:springboot /home/springboot/openlogic-openjdk-8u352-b08-linux-x64 -R USER springboot # Set the user to springboot. ENV JAVA_HOME=/home/springboot/openlogic-openjdk-8u352-b08-linux-x64 # Set environment variables. ENV PATH=$JAVA_HOME/bin:$PATH \ CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar WORKDIR /home/springboot/ # Set the working directory of the image.
- Press Esc and enter :wq to save the Dockerfile and exit.
- Build an image.
- Run docker images to check whether the image is built successfully.
Figure 1 Checking the built image
- Run vi dockerfile to write a Dockerfile as follows:
- Log in to the SWR console and create an organization.
Example: Create an organization testawa0306.
- Push the image to the organization created in 5.
- Log in to the SWR console as root.
- Tag the image.
- Push the image to the organization created in 5.
docker push swr.ap-southeast-3.myhuaweicloud.com/testawa0306/0penjdk:v8.8
After an image is pushed, you can find it on the My Images page of the SWR console.
- (Optional) Use the pushed image to deploy a workload in CCE.
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