Docker基础教程

MicLon原创2025年1月12日大约 2 分钟

初始环境

卸载旧版本

其他配置项

安装docker

镜像加速

Linux

  1. 修改配置文件
sudo vim /etc/docker/daemon.json
  1. 添加国内镜像
{
  "registry-mirrors": [
    "https://hub-mirror.c.163.com",
    "https://mirror.ccs.tencentyun.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}
  1. 更新镜像缓存
sudo systemctl daemon-reload
sudo systemctl restart docker

MAC & Windows

右键点击桌面顶栏的 docker 图标,选择 Preferences ,在 Daemon 标签(Docker 17.03 之前版本为 Advanced 标签)下的 Registry mirrors 列表中加入下面的镜像地址:

http://f1361db2.m.daocloud.io
或
http://hub-mirror.c.163.com

点击 Apply & Restart 按钮使设置生效。

镜像管理

搜索镜像

docker search [镜像名称]

安装镜像

使用 pull 可以从 仓库open in new window下载镜像

docker pull lorisleiva/laravel-docker

但官方组织中的镜像可以省略组织名,如 hello-world 是官方镜像可以简写

docker pull hello-world

使用 run 命令用来通过镜像生成容器,如果镜像不存在会从仓库下载,也就是具有 pull 功能

docker run hello-world

查看镜像

docker images
Loading...