docker镜像和仓库管理练习

news2025/4/19 19:28:48

目录

一.使用mysql:5.6和owncloud镜像,构建一个个人网盘

二.安装搭建私有仓库Harbor

三.编写Dockerfile制作Web应用系统nginx镜像,生成镜像nginx:v1.1,并推送其到私有仓库,以下为具体要求:

四.Dockerfile快速搭建自己专属的LAMP环境,生成镜像lamp:v1.1,并推送到私有仓库,以下为具体要求:


 

 

一.使用mysql:5.6和owncloud镜像,构建一个个人网盘

[root@localhost ~]# docker pull mysql:5.6

[root@localhost ~]# docker pull owncloud

[root@localhost ~]# docker run -itd --name mydb --env MYSQL_ROOT_PASSWORD=SLB123 mysql:5.6

[root@localhost ~]# docker run -itd --name myweb -p 80:80 --link mydb:mydb owncloud

使用IP进行访问,用admin+运行容器时设置的密码登录 

1276cdbed3fa44c4b1b8101e86e4c9a2.png

1f5865ef81634ca39b52e33c1055b491.png

二.安装搭建私有仓库Harbor

[root@localhost ~]# cd /usr/local/

[root@localhost local]# rz -E
rz waiting to receive.
[root@localhost local]# ll
total 651916
drwxr-xr-x. 2 root root         6 Apr 11  2018 bin
-rw-r--r--  1 root root  59383631 Aug 20 15:59 docker-compose-linux-x86_64
drwxr-xr-x. 2 root root         6 Apr 11  2018 etc
drwxr-xr-x. 2 root root         6 Apr 11  2018 games
-rw-r--r--  1 root root 608175520 Aug 20 16:01 harbor-offline-installer-v2.8.4.tgz
drwxr-xr-x. 2 root root         6 Apr 11  2018 include
drwxr-xr-x. 2 root root         6 Apr 11  2018 lib
drwxr-xr-x. 2 root root         6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root         6 Apr 11  2018 libexec
drwxr-xr-x. 2 root root         6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root        49 Jul 23 08:59 share
drwxr-xr-x. 2 root root         6 Apr 11  2018 src

[root@localhost local]# mv docker-compose-linux-x86_64 ./bin/docker-compose

[root@localhost local]# chmod +x /usr/local/bin/docker-compose

[root@localhost local]# docker-compose version
Docker Compose version v2.20.3

[root@localhost local]# tar -xf harbor-offline-installer-v2.8.4.tgz
[root@localhost harbor]# ll
total 597536
-rw-r--r-- 1 root root      3639 Aug 15 17:53 common.sh
-rw-r--r-- 1 root root 611834153 Aug 15 17:54 harbor.v2.8.4.tar.gz
-rw-r--r-- 1 root root     12499 Aug 15 17:53 harbor.yml.tmpl
-rwxr-xr-x 1 root root      2725 Aug 15 17:53 install.sh
-rw-r--r-- 1 root root     11347 Aug 15 17:53 LICENSE
-rwxr-xr-x 1 root root      1881 Aug 15 17:53 prepare

[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# hostname
harborslb.com
[root@localhost harbor]# vim harbor.yml 

更改hostname和端口,注释https加密访问部分的内容,下方的password后面用于登录 

63fe311a84374b87ac9d6cbeaa9f4c4d.png

 

[root@localhost harbor]# ./install.sh 
√----Harbor has been installed and started successfully.----
[root@localhost harbor]# docker-compose ls
NAME                STATUS              CONFIG FILES
harbor              running(9)          /usr/local/harbor/docker-compose.yml

0513dceb533347878be57fc59346f58b.png

a85c4dba772b4058ac0731e1b5440bc6.png 

三.编写Dockerfile制作Web应用系统nginx镜像,生成镜像nginx:v1.1,并推送其到私有仓库,以下为具体要求:

(1)基于centos基础镜像

(2)指定作者信息

(3)安装nginx服务,将提供的dest目录(提供默认主页index.html)传到镜像内,并将dest目录内的前端文件复制到nginx的工作目录

(4)暴露80端口

(5)设置服务自启动

(6)验证镜像

[root@harborslb centos]# vim /etc/docker/daemon.json
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["192.168.2.190:8080"]
}

[root@localhost centos]# ll
total 1056
drwxr-xr-x 2 root root      24 Aug 24 14:21 dest
-rw-r--r-- 1 root root     162 Aug 24 14:21 Dockerfile
-rw-r--r-- 1 root root 1073322 Aug  9 19:20 nginx-1.22.0.tar.gz

[root@localhost centos]# vim Dockerfile
FROM centos
MAINTAINER "sulibao <sulibao2003@163.com>"
ADD nginx-1.22.0.tar.gz /centos
COPY dest /usr/share/nginx/html
EXPOSE 80
CMD ["nginx","-g","daemon off;"]

[root@localhost centos]# docker build -t nginx:v1.1 .
[+] Building 41.7s (8/8) FINISHED                                    docker:default
 => [internal] load build definition from Dockerfile                           0.0s
 => => transferring dockerfile: 201B                                           0.0s
 => [internal] load .dockerignore                                              0.0s
 => => transferring context: 2B                                                0.0s
 => [internal] load metadata for docker.io/library/centos:latest               1.1s
 => [1/3] FROM docker.io/library/centos@sha256:a27fd8080b517143cbbbab9dfb7c8  40.0s
 => => resolve docker.io/library/centos@sha256:a27fd8080b517143cbbbab9dfb7c85  0.0s
 => => sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd 762B / 762B  0.0s
 => => sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3a 529B / 529B  0.0s
 => => sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c5 2.14kB / 2.14kB  0.0s
 => => sha256:a1d0c75327776413fa0db9ed3adcdbadedc95a662eb1 83.52MB / 83.52MB  35.3s
 => => extracting sha256:a1d0c75327776413fa0db9ed3adcdbadedc95a662eb1d360dad8  4.5s
 => [internal] load build context                                              0.0s
 => => transferring context: 1.07MB                                            0.0s
 => [2/3] ADD nginx-1.22.0.tar.gz /centos                                      0.5s
 => [3/3] COPY dest /usr/share/nginx/html                                      0.0s
 => exporting to image                                                         0.0s
 => => exporting layers                                                        0.0s
 => => writing image sha256:7ae3a2d1a01c44857fa7946d9c4d83fb1b1d703ddbcebf4ed  0.0s
 => => naming to docker.io/library/nginx:v1.1                                  0.0s

[root@localhost centos]# docker tag nginx:v1.1 192.168.2.190:8080/nginx:v1.1

[root@harborslb centos]# docker login http://192.168.2.190:8080
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

[root@harborslb centos]# docker push 192.168.2.190:8080/nginx:v1.1

[root@harborslb centos]# docker pull 192.168.2.190:8080/nginx:v1.1

[root@harborslb centos]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED          SIZE
nginx                           v1.1      7ae3a2d1a01c   2 hours ago     238MB
goharbor/harbor-exporter        v2.8.4    b8d33e28ec68   8 days ago       97.7MB
goharbor/redis-photon           v2.8.4    7b7324d651ca   8 days ago       120MB
goharbor/trivy-adapter-photon   v2.8.4    91d8e9f0b21a   8 days ago       464MB
goharbor/notary-server-photon   v2.8.4    a46f91560454   8 days ago       113MB
goharbor/notary-signer-photon   v2.8.4    da66bd8d944b   8 days ago       110MB
goharbor/harbor-registryctl     v2.8.4    805b38ca6bee   8 days ago       141MB
goharbor/registry-photon        v2.8.4    756769e94123   8 days ago       79MB
goharbor/nginx-photon           v2.8.4    375018db778b   8 days ago       116MB
goharbor/harbor-log             v2.8.4    8a2045fb24d2   8 days ago       124MB
goharbor/harbor-jobservice      v2.8.4    97808fc10f64   8 days ago       141MB
goharbor/harbor-core            v2.8.4    c26fcd0714d8   8 days ago       164MB
goharbor/harbor-portal          v2.8.4    4a8b0205c0f9   8 days ago       124MB
goharbor/harbor-db              v2.8.4    5b8af16d7420   8 days ago       174MB
goharbor/prepare                v2.8.4    bdbf974d86ce   8 days ago       166MB
mysql                           5.6       dd3b2a5dcb48   20 months ago    303MB
owncloud                        latest    327bd201c5fb   4 years ago      618MB

[root@localhost lamp]# docker run --name mynginx -itd nginx:v1.1 
3037a148018a4bbfe88c18526eed75fd82333facbf296a99dd04467456ac4e94

四.Dockerfile快速搭建自己专属的LAMP环境,生成镜像lamp:v1.1,并推送到私有仓库,以下为具体要求:

(1)基于centos:6基础镜像

(2)指定作者信息

(3)安装hhttpd、mysql、mysql-server、php、php-mysql、php-gd

(4)暴露80和3306端口

(5)设置服务自启动

(6)验证镜像

[root@localhost lamp]# vim Dockerfile
FROM centos
MAINTAINER "sulibao <sulibao2003@163.com>"
RUN yum -y install httpd mysql mysql-server php php-mysql php-gd
EXPOSE 80 3306

[root@localhost lamp]# docker build -t lamp:v1.1 .
[+] Building 5.0s (6/6) FINISHED                                                        docker:default
 => [internal] load build definition from Dockerfile                                              0.0s
 => => transferring dockerfile: 199B                                                              0.0s
 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [internal] load metadata for docker.io/library/centos:7                                       3.7s
 => [1/2] FROM docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8  0.0s
 => CACHED [2/2] RUN yum -y install httpd mysql mysql-server php php-mysql php-gd                 0.0s
 => exporting to image                                                                            1.3s
 => => exporting layers                                                                           1.3s
 => => writing image sha256:27d9fbc1eb61eed01309bb6f987c2c041c6efefa1eb27b3318ea1ea18745ab99      0.0s
 => => naming to docker.io/library/lamp:v1.1                                                      0.0s

[root@localhost lamp]# docker push lamp:v1.1 192.168.2.190:8080/lamp:v1.1

[root@localhost lamp]# docker pull 192.168.2.190:8080/lamp:v1.1

[root@localhost lamp]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED         SIZE
lamp                            v1.1      27d9fbc1eb61   3 minutes ago   569MB
nginx                           v1.1      7ae3a2d1a01c   2 hours ago     238MB
goharbor/harbor-exporter        v2.8.4    b8d33e28ec68   8 days ago      97.7MB
goharbor/redis-photon           v2.8.4    7b7324d651ca   8 days ago      120MB
goharbor/trivy-adapter-photon   v2.8.4    91d8e9f0b21a   8 days ago      464MB
goharbor/notary-server-photon   v2.8.4    a46f91560454   8 days ago      113MB
goharbor/notary-signer-photon   v2.8.4    da66bd8d944b   8 days ago      110MB
goharbor/harbor-registryctl     v2.8.4    805b38ca6bee   8 days ago      141MB
goharbor/registry-photon        v2.8.4    756769e94123   8 days ago      79MB
goharbor/nginx-photon           v2.8.4    375018db778b   8 days ago      116MB
goharbor/harbor-log             v2.8.4    8a2045fb24d2   8 days ago      124MB
goharbor/harbor-jobservice      v2.8.4    97808fc10f64   8 days ago      141MB
goharbor/harbor-core            v2.8.4    c26fcd0714d8   8 days ago      164MB
goharbor/harbor-portal          v2.8.4    4a8b0205c0f9   8 days ago      124MB
goharbor/harbor-db              v2.8.4    5b8af16d7420   8 days ago      174MB
goharbor/prepare                v2.8.4    bdbf974d86ce   8 days ago      166MB
mysql                           5.6       dd3b2a5dcb48   20 months ago   303MB
owncloud                        latest    327bd201c5fb   4 years ago     618MB

[root@localhost lamp]# docker run --name mylamp -itd lamp:v1.1 
9ec40c703103b6dcea549b528028a3e46fb783bb84f0e93e91ef096b86d21e4b

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/923971.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何使用操作系统迁移工具将 Windows 10 迁移到固态硬盘?

尽管微软已于2021年10月5日发布了Windows 11&#xff0c;但Windows 10仍然是很受欢迎的Windows桌面操作系统。如果您是Windows 10用户&#xff0c;在以下情况下您可能希望将Windows 10迁移到SSD&#xff1a; ​您当前的系统安装在硬盘上&#xff0c;启动计算机和加载程序的时间…

做一个蛋糕店小程序需要哪些步骤?

对于一些不懂技术的新手来说&#xff0c;创建蛋糕店小程序可能会感到有些困惑。但是&#xff0c;有了乔拓云平台的帮助&#xff0c;你可以轻松地创建自己的蛋糕店小程序。下面&#xff0c;我将为大家详细介绍一下具体的操作步骤。 首先&#xff0c;登录乔拓云平台并进入后台管理…

实验篇——基因组共线性分析

实验篇——基因组共线性分析 文章目录 前言一、名词解释二、实操1. 文件准备2. 共线性分析3. 共线性可视化4. 多个物种共线性可视化 总结 前言 本文主要介绍了使用TBtools软件来进行基因组间的共线性分析&#xff0c;并进行可视化。 一、名词解释 基因组共线性分析是一种用于比…

Unity3d:GameFramework解析:实体,对象池,资源管理,获取计数,引用计数,自动释放

基本概念 1.GF万物基于引用池IReference 2.ObjectBase : IReference类的m_Target持有unity中Mono&#xff0c;资源&#xff0c;GameObejct 3.AssetObject : ObjectBase类m_Target持有Assetbundle中的Asset&#xff0c;具有获取&#xff0c;引用两个计数管理释放 4.ResourceObj…

什么是网络安全工程师,你想知道的都在这里!

随着互联网的发展和大数据时代的到来&#xff0c;网络已经日渐深入到我们生活、工作中的方方面面&#xff0c;社会信息化和信息网络化&#xff0c;突破了应用信息在时间和空间上的障碍&#xff0c;使信息的价值不断提高。但是&#xff0c;与此同时&#xff0c;网页篡改、计算机…

JMeter性能测试(中)

断言 让程序自动判断预期结果和实际结果是否一致。 响应断言 例子2&#xff1a;可以在同一个HTTP请求下包含多个响应断言 例子1&#xff1a; 步骤; 添加线程组添加HTTP请求添加响应断言 测试字段&#xff1a;要检查的项&#xff08;实际结果&#xff09;模式匹配规则&#…

25-非父子通信 - event bus 事件总线

作用:非父子组件之间&#xff0c;进行简易消息传递。(复杂场景 -> Vuex) 1.创建一个都能访问到的事件总线(空 Vue 实例) -> utils/EventBus.js import Vue from vue const Bus new Vue() export default Bus 2. A组件(接收方),监听 Bus实例 的事件(支持多个组件同时监…

【C++小项目】实现一个日期计算器

目录 Ⅰ. 引入 Ⅱ. 列轮廓 Ⅲ. 功能的实现 构造函数 Print 判断是否相等 | ! ➡️: ➡️!: 判断大小 > | > | < | < ➡️>&#xff1a; ➡️<&#xff1a; ➡️>&#xff1a; ➡️<&#xff1a; 加减天数 | | - | - ➡️&#xff1a;…

CSS 盒子模型

前言 盒子模型-组成 CSS盒子模型是一种用来描述元素在页面布局中占据空间的模型。它将每个元素看作由内容区域、内边距、边框和外边距组成的一个矩形框。 盒子模型的组成部分包括&#xff1a; 内容区域&#xff08;Content&#xff09;&#xff1a;显示元素的实际内容&#xf…

嵌入式Linux开发实操(十一):ETH网络接口开发

# 前言 嵌入式linux也有些是支持网口的,比如RGMII,嵌入式系统资源支持以太网和其他基本接口的硬件平台(板上或片上系统),有充足的NOR或NAND Flash闪存,用于容纳OS、lib库、fileSystem文件系统、APP应用程序、Bootloader引导程序等。嵌入式Linux是开源的、可修改的,并且…

Grounded Language-Image Pre-training论文笔记

Title&#xff1a;Grounded Language-Image Pre-training Code 文章目录 1. 背景2. 方法&#xff08;1&#xff09;Unified Formulation传统目标检测grounding目标检测 &#xff08;2&#xff09;Language-Aware Deep Fusion&#xff08;3&#xff09;Pre-training with Scala…

【JavaEE基础学习打卡06】JDBC之进阶学习PreparedStatement

目录 前言一、PreparedStatement是什么二、重点理解预编译三、PreparedStatement基本使用四、Statement和PreparedStatement比较1.PreparedStatement效率高2.PreparedStatement无需拼接参数3.PreparedStatement防止SQL注入 总结 前言 &#x1f4dc; 本系列教程适用于JavaWeb初学…

Kali Linux中的SQL注入攻击如何进行

Kali Linux中的SQL注入攻击如何进行&#xff1f; 什么是SQL注入攻击&#xff1f; SQL注入是一种常见的Web应用程序漏洞&#xff0c;攻击者可以通过恶意构造的SQL查询字符串&#xff0c;绕过应用程序的验证和过滤&#xff0c;进而访问或操纵数据库中的数据。这可能导致泄露敏感…

Linux 命令大全(看这一篇就足够)

目录 第一章&#xff1a;Linux目录结构 第一节&#xff1a;基本介绍 第二节&#xff1a;Linux具体目录结构 第二章&#xff1a;Linux常用命令 第一节&#xff1a;目录处理命令 2.1.1 命令格式 2.1.2 列出目录的内容&#xff1a;ls 命令 2.1.3 创建目录&#xff1a;mkdi…

Wlan——锐捷智分网络解决方案及其配置

目录 智分解决方案 一代智分解决方案 二代智分解决方案 三代智分解决方案 智分解决方案 技术原理 隧道建立 智分方案的配置 配置基础信息 配置微AP的无线信号 调整微AP的射频参数 宿舍场景特点&#xff1a;房间小&#xff0c;单个房间用户少&#xff0c;房间密集&am…

第 5 章 栈(1)(介绍,应用场景,入门)

5.1栈的一个实际需求 请输入一个表达式 计算式:[722-51-53-3] 点击计算【如下图】 请问: 计算机底层是如何运算得到结果的&#xff1f; 注意不是简单的把算式列出运算,因为我们看这个算式 7 * 2 * 2 - 5, 但是计算机怎么理解这个算式的(对计算机而言&#xff0c;它接收到的就…

用名字来杀,杀不死的进程

杀死进程 这是进程的名字 docker-prox pkill -f "docker-prox"查看是否杀死 netstat -tlnp | grep :7006

echarts 的dataZoom滑块两端文字被遮挡

问题&#xff1a; 期望&#xff1a; 解决方案&#xff1a; 1&#xff1a;调整宽度&#xff08;4版本的没有width属性&#xff09; 2. 参考&#xff1a;echarts图标设置dataZoom拖拽时间轴时自动调整两侧文字的位置_datazoom 位置_乌栖曲的博客-CSDN博客 设置文字的定位 cons…

RT-Thread内核学习

内核框架 内核是操作系统最基础也是最重要的部分&#xff0c;内核处于硬件层之上&#xff0c;内核部分包括内核库、实时内核实现。 内核库是为了保证内核能够独立运行的一套小型的类似C库的函数实现子集。这部分根据编译器不同自带C库的情况也会不同。 当使用GNU GCC编译器时&…

2023年高教社杯 国赛数学建模思路 - 复盘:光照强度计算的优化模型

文章目录 0 赛题思路1 问题要求2 假设约定3 符号约定4 建立模型5 模型求解6 实现代码 建模资料 0 赛题思路 &#xff08;赛题出来以后第一时间在CSDN分享&#xff09; https://blog.csdn.net/dc_sinor?typeblog 1 问题要求 现在已知一个教室长为15米&#xff0c;宽为12米&…