【Docker】Docker实战

您所在的位置:网站首页 刃影实战 【Docker】Docker实战

【Docker】Docker实战

2023-07-10 01:38| 来源: 网络整理| 查看: 265

文章目录 搭建nginx服务搭建私有库Busybox阿里云上创建私有库

搭建nginx服务

首先拉取nginx的镜像。

docker pull nginx:1.24.0

image-20230709172939186

以后台的方式运行nginx,并且创建一个shell进行交互。

docker run --name nginx1 --rm -it -p 8080:80 nginx:1.24.0 bash #在交互的bash中启动nginx nginx

image-20230709210102225

image-20230709212855250

下面修改nginx的首页为welcome to my nginx1!

cd /usr/share/nginx/html cat index.html echo "Welcome to my nginx1!" > index.html

image-20230709210634848

通过浏览器访问nginx1,成功访问到nginx。

image-20230709212958966

搭建私有库 Busybox

BusyBox 是一个集成了三百多个最常用 Linux 命令和工具的软件。 BusyBox 包含了一些简单的工具,例如 ls、 cat 和 echo 等等,还包含了一些更大、更复杂的工具,例如grep、 find、 mount 以及 telnet。

BusyBox 就好像是个大工具箱,它集成压缩了 Linux 的许多工具和命令,也包含了 Linux 系统的自带的 shell。 busybox 是一个集成了一百多个最常用 linux 命令和工具的软件,他甚至还集成了一个 http 服务器和一个 telnet 服务器,而所有这一切功能却只有区区 1M 左右的大小 。

Busybox下载:

wget https://busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/busybox-x86_64 --no-check-certificate mv busybox-x86_64 busybox chmod +x busybox ./busybox

image-20230709214231699

bosybox的使用

./busybox ls ./

image-20230709214311010

./busybox ping www.baidu.com

image-20230709214437916

阿里云上创建私有库

进入阿里云 https://www.aliyun.com/ ,选择容器镜像服务。

image-20230709215742161

创建仓库:

image-20230709215958162

登陆阿里云镜像,阿里云提供了完整的命令:

image-20230709220217231

接下来我们将本地的busybox,并上传到我们的私有仓库中。

docker pull busybox:latest docker tag busybox:latest registry.cn-hangzhou.aliyuncs.com/westmo/req1:v0.3 docker push registry.cn-hangzhou.aliyuncs.com/westmo/req1:v0.3

image-20230709221320550

查看私有仓库是否有镜像文件:

image-20230709221801455

下面我们试着拉取阿里云上面的镜像文件:

docker pull registry.cn-hangzhou.aliyuncs.com/westmo/req1:v0.3

image-20230709222038601

退出仓库:

docker logout registry.cn-hangzhou.aliyuncs.com

image-20230709222256378



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3