1、查看并导入容器镜像
1.1、查看及导入容器镜像包
- [root@plat1 docker]# ls
- aa.zip Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64.tar.xz
复制代码 1.2、导入容器镜像
docker load -i Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64.tar.xz
- [root@plat1 docker]# docker load -i Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64.tar.xz
- Loaded image: cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405
复制代码 1.3、查看导入的容器镜像
docker images
- [root@plat1 aa]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 202405 e8adb7da708a 7 months ago 246MB
复制代码 2、编写dockerfile文件并封装镜像
2.1、配置dockerfile文件并写
2.1.1、dockerfile文件里参数解释
- FROM #导入系统的docker容器镜像名
- MAINTAINER #作者名称等
- RUN #运行创建等命令
- RUN #运行创建等命令
- COPY #拷贝当前目录下的文件到容器目录,目录没有需要创建
- COPY #拷贝当前目录下的文件到容器目录,目录没有需要创建
- ENV #设置环境变量,且永久生效
复制代码 2.1.2、下面是具体修改的dockerfile文件
vim Dockerfile
- [root@plat1 aa]# vim Dockerfile
- FROM cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405
- MAINTAINER malu
- RUN mkdir -p /usr/lib/locale/zh_CN.utf8
- RUN mkdir -p /usr/share/locale/zh_CN
- COPY zh_CN/ /usr/share/locale/zh_CN/
- COPY zh_CN.utf8/ /usr/lib/locale/zh_CN.utf8/
- ENV LANG=zh_CN.UTF-8
复制代码 2.2、查看容器镜像并对当前镜像进行修改
2.2.1、查看前容器镜像
docker images
- [root@plat1 aa]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 202405 e8adb7da708a 7 months ago 246MB
复制代码 2.2.2、对当前容器镜像进行修改
docker build -t cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405 .
- [root@plat1 aa]# docker build -t cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405 .
- Sending build context to Docker daemon 11.8MB
- Step 1/7 : FROM cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405
- ---> e8adb7da708a
- Step 2/7 : MAINTAINER malu
- ---> Running in 13bbaadb5fcc
- Removing intermediate container 13bbaadb5fcc
- ---> b005ddab0be0
- Step 3/7 : RUN mkdir -p /usr/lib/locale/zh_CN.utf8
- ---> Running in b7fee2db3fd6
- Removing intermediate container b7fee2db3fd6
- ---> 410bb59aa4c9
- Step 4/7 : RUN mkdir -p /usr/share/locale/zh_CN
- ---> Running in 501714361b68
- Removing intermediate container 501714361b68
- ---> 735a5cca6ba4
- Step 5/7 : COPY zh_CN/ /usr/share/locale/zh_CN/
- ---> 0301fb0def1b
- Step 6/7 : COPY zh_CN.utf8/ /usr/lib/locale/zh_CN.utf8/
- ---> 9cf8be5e9af4
- Step 7/7 : ENV LANG=zh_CN.UTF-8
- ---> Running in f94ca5767b7c
- Removing intermediate container f94ca5767b7c
- ---> a3a40e17be58
- Successfully built a3a40e17be58
- Successfully tagged cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405
复制代码 2.3、查看当前容器并给容器打标签
2.3.1、查看修改后的容器镜像
docker images
- [root@plat1 aa]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 202405 a3a40e17be58 4 seconds ago 257MB
复制代码 2.3.2、对当前容器镜像进行打标签
docker tag cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405 cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220
- [root@plat1 aa]# docker tag cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:202405 cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220
复制代码 2.3.3、查看打过标签的容器镜像情况
docker images
- [root@plat1 aa]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 202405 a3a40e17be58 About a minute ago 257MB
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 20241220 a3a40e17be58 About a minute ago 257MB
复制代码 2.4、运行容器及验证
2.4.1、运行新容器镜像
docker run -dit cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220
运行新容器cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220
- [root@plat1 aa]# docker run -dit cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220
- 5d031935e053ec7712419128abf1bbacf519860bd6851de5c2d14b96bc77577b
复制代码 2.4.2、查看新容器镜像运行情况
docker ps
查看cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220 容器运行情况
- [root@plat1 aa]# docker ps
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 5d031935e053 cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220 "/bin/bash" 8 seconds ago Up 7 seconds competent_chatelet
复制代码 2.4.3、进入competent_chatelet容器内
docker exec -it competent_chatelet /bin/bash
进入cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220 对应运行的容器里。
- [root@plat1 aa]# docker exec -it competent_chatelet /bin/bash
复制代码 2.4.4、查看字体环境变量
locale输入LANG=zh_CN.UTF-8,说明中文环境变量已经设置乐成
- [root@5d031935e053 /]# locale
- LANG=zh_CN.UTF-8
- LC_CTYPE="zh_CN.UTF-8"
- LC_NUMERIC="zh_CN.UTF-8"
- LC_TIME="zh_CN.UTF-8"
- LC_COLLATE="zh_CN.UTF-8"
- LC_MONETARY="zh_CN.UTF-8"
- LC_MESSAGES="zh_CN.UTF-8"
- LC_PAPER="zh_CN.UTF-8"
- LC_NAME="zh_CN.UTF-8"
- LC_ADDRESS="zh_CN.UTF-8"
- LC_TELEPHONE="zh_CN.UTF-8"
- LC_MEASUREMENT="zh_CN.UTF-8"
- LC_IDENTIFICATION="zh_CN.UTF-8"
- LC_ALL=
复制代码 2.4.4、验证输入中文是否正常,如下体现正常
- [root@5d031935e053 /]# vi 1.txt
- [root@5d031935e053 /]# cat 1.txt
- 的房间里的杰夫
复制代码 2.5退出当前运行的容器
- [root@5d031935e053 /]# exit
- exit
复制代码 2.6、导出当前做好的容器镜像
2.6.1、查看容器镜像
docker images
- [root@plat1 aa]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 202405 a3a40e17be58 13 minutes ago 257MB
- cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform 20241220 a3a40e17be58 13 minutes ago 257MB
复制代码 2.6.2、导出容器镜像
docker save cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220 -o Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64-20241220.tar.xz
- [root@plat1 aa]# docker save cr.kylinos.cn/v10sp3-2403/kylin-server-v10-sp3-2403-general-alpha20-x86_64-platform:20241220 -o Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64-20241220.tar.xz
复制代码 2.6.3、查看导出镜像情况
- [root@plat1 aa]# ls
- Dockerfile Kylin-Server-V10-SP3-2403-Release-Docker-platform-20240426-X86_64-20241220.tar.xz zh_CN zh_CN.utf8
- [root@plat1 aa]#
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |