In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
At present, the operating systems used by my company are all centos7.4 versions, and of course, applications are also deployed on centos, so if you use docker deployment, you will naturally want to build your own application image based on centos image. However, you can also build basic framework images between centos basic image and application image, such as basic JDK image, Python environment image, and so on. I believe you have also encountered the construction of an image to find that when the application is deployed, the printed Chinese is garbled, and the time of the log shows the UTC time, which is 8 hours less than Beijing time. When you want to see if a process is up, you find that the telnet command, the ps command, the netstat command is not available, and when you want to edit the file, you find that the vim command cannot be used. Today we'll take a look at how to build an enhanced centos image based on centos images.
The construction of image warehouse
Before building our own image, we need a place to store our image so that we can use it directly. There are probably two ways of thinking: first, build it on your own machine, then upload it to your own cloud disk by docker save-o xxx.tar.gz xxx-image:v1.0, download it locally when you use it, and then docker load-I xxx.tar.gz. This method is fine, but it is cumbersome (you have to find the directory when you package, upload or download, and load); second, to create your own docker image registry, you only need to re-tag the locally built image and docker push to complete it; when downloading, you only need docker pull, and you can all be done on the command line, and you all feel like pants.
Having said that, let's take a look at how to build our own image warehouse. (in this article, we only use Aliyun's warehouse and build our own namespace.) of course, we can also apply for a CVM ourselves, and then set up a private server.
Log in to Aliyun first, and then find the location of the container image service from the service, as shown below:
Click the container image service to enter the image warehouse creation interface as follows
Click create to go to the create warehouse interface
After completing the information, click next to select how to upload the mirror image.
Because my requirement is to build from the local warehouse, but I think the local warehouse building is the most flexible way.
Once you have created the location of the image storage, you can create a Dockerfile locally to build your own image
Build an enhanced centos image
1. First, create a Dockerfile file and put the following in the file
FROM centosMAINTAINER terry.king "1575639478@qq.com" # defines the time zone parameter ENV TZ=Asia/ShanghaiRUN ls-snf / usr/share/zoneinfo/$TZ / etc/localtime & & echo'$TZ' > / etc/timezone# setting Encoding RUN localedef-c-f UTF-8-I zh_CN zh_CN.utf8ENV LC_ALL "zh_CN.UTF-8" # install the basic yum package RUN yum install-y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel patch net-tools Iproute telnet bind-utils wget kde-l10n-Chinese glibc-common
2. Log in to Aliyun Docker Registry
Sudo docker login-- username= your Aliyun account registry.cn-shenzhen.aliyuncs.com
The user name used to log in is the full name of the Aliyun account, and the password is the password set when activating the service.
You can change the login password on the home page of the product console. Set the registry login password on the left side of the second button to create an image warehouse
3. Build an image and push it to Registry
$docker build-t terrylmay/centos. $docker tag terrylmay/centos registry.cn-shenzhen.aliyuncs.com/terrylmay/centos: [image version number] $docker push registry.cn-shenzhen.aliyuncs.com/terrylmay/centos: [image version number]
The default image version number is latest
Summary
In this way, a series of problems mentioned in the preface can be solved when building the application image. It is convenient for you to quickly build your own application image.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.