Docker

2021-02-07, updated 2021-09-12

Docker 镜像加速

国内从DockerHub拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker官方和国内很多云服务商都提供了国内加速器服务,例如:

当配置某个加速器地址之后,若发现拉取不到镜像,请切换到另一个加速器地址。国内各大云服务商均提供了Docker镜像加速服务,建议根据运行Docker地云平台选择对应地镜像加速服务。

我们以Docker官方加速器为例进行介绍。

Ubuntu14.04、Debian7

对于使用upstart地系统而言,编辑/etc/default/docker文件,在其中地DOCKER_OPTS中配置加速器地址:

DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com"

windows配置修改

修改文件C:\Users\(username)\AppData\Roaming\Docker\settings.json

{
  "settingsVersion": 6,
  "autoStart": true,
  "analyticsEnabled": true,
  "useCloudCli": true,
  "displayedTutorial": true,
  "displayed15063Deprecation": false,
  "displayRestartDialog": true,
  "displaySwitchWinLinContainers": true,
  "displaySwitchVersionPack": true,
  "latestBannerKey": null,
  "acceptCanaryUpdates": false,
  "dataFolder": "C:\\ProgramData\\DockerDesktop\\vm-data",
  "memoryMiB": 512,
  "swapMiB": 512,
  "cpus": 1,
  "diskSizeMiB": 65536,
  "vpnkitCIDR": "192.168.65.0/28",
  "socksProxyPort": 0,
  "proxyHttpMode": false,
  "overrideProxyHttp": "",
  "overrideProxyHttps": "",
  "overrideProxyExclude": "",
  "filesharingDirectories": [],
  "synchronizedDirectories": [],
  "useDnsForwarder": true,
  "dns": "8.8.8.8",
  "kubernetesEnabled": false,
  "showKubernetesSystemContainers": false,
  "kubernetesInitialInstallPerformed": false,
  "versionPack": "default",
  "executableDate": "",
  "useWindowsContainers": false,
  "swarmFederationExplicitlyLoggedOut": false,
  "activeOrganizationName": null,
  "exposeDockerAPIOnTCP2375": false,
  "lifecycleTimeoutSeconds": 600,
  "customWslDistroDir": null,
  "wslEngineEnabled": true,
  "integratedWslDistros": [],
  "enableIntegrationWithDefaultWslDistro": false,
  "skipUpdateToWSLPrompt": false,
  "skipWSLMountPerfWarning": false,
  "sharedDrives": null,
  "networkCIDR": null,
  "diskPath": null
}
words: 524 tags: docker