Docker系列 | 01 Docker 基本介绍与使用

一、 Docker 介绍

    Docker - 用于开发、发布和运行应用程序的平台。并且拥有三大优势:灵活轻量级应用隔离

1、Docker 架构 --- C/S架构

 2、Docker 三大核心

  •     image 镜像        ---    可以创建Docker容器
  •     container 容器   ---    是镜像创建的运行实例
  •     repository 仓库  ---    集中保存镜像

二、 Docker 安装环境

操作系统
centos 7

安装过程:略

配置 Docker 加速器 并 重启

[root@centos-7-node ~]# cat <<END > /etc/docker/daemon.json
> {
>     "registry-mirrors": [
>         "https://ipbtg5l0.mirror.aliyuncs.com"
>     ]
> }
> END
[root@centos-7-node ~]# systemctl daemon-reload && systemctl restart docker

三、 Docker 基础命令

1)镜像相关命令

    (1)、查看当前 Docker 的所有镜像

[root@centos-7-node ~]# docker images

     (2)、查看 Docker 仓库中的 busybox 镜像

[root@centos-7-node ~]# docker search busybox

    (3)、拉取 busybox 镜像

[root@centos-7-node ~]# docker pull busybox:1.28.4

    (4)、给镜像进行打标签 

[root@centos-7-node ~]# docker tag busybox:1.28.4 testbusybox:test

    (5)、将 busybox 镜像导出

[root@centos-7-node ~]# docker save -o busybox.tgz busybox:1.28.4

    (6)、将 busybox 镜像导入

[root@centos-7-node ~]# docker load -i busybox.tgz

2)容器相关命令

    (1)、创建一个容器

[root@centos-7-node ~]# docker create -it --name busybox busybox:1.28.4 /bin/sh

(2)、启动一个容器

[root@centos-7-node ~]# docker start busybox

    (3)、删除容器

[root@centos-7-node ~]# docker stop busybox
[root@centos-7-node ~]# docker rm busybox

    (4)、直接运行容器

[root@centos-7-node ~]# docker run -d --name busybox busybox:1.28.4 /bin/sh

实战 - 使用 Docker 实现 Nginx 网站

[root@centos-7-node ~]# docker pull nginx:1.18.0
[root@centos-7-node ~]# docker images
[root@centos-7-node ~]# docker run -d --name nginx -p 1888:80 -v /wuyanzu:/usr/share/nginx/html/ nginx:1.18.0
[root@centos-7-node ~]# echo "I am 广东吴彦祖" > /wuyanzu/index.html
[root@centos-7-node ~]# curl 127.0.0.1:1888

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

白帽菜菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值