windows下docker使用及注意事项

/ docker / 没有评论 / 2032浏览

windows container模式下,pull镜像会失败

no matching manifest for windows/amd64 in the manifest list entries

windows container模式下会存在问题,再次切换到linux container模式下,启动会出现问题

out of memory

解决memory问题

右击docker状态栏的图标,选择设置(settings),再将advanced下的memory从2048修改为1280,自动重启后即可成

获取阿里云镜像地址

  1. docker默认下载的镜像基本上都是在国外,下载速度会非常缓慢,需要进行设置镜像加速
  2. 使用阿里云加速的方法:

添加镜像加速器

到阿里云注册账号,找到镜像加速器,找到里面的地址(每个人都不同),直接复制到settings->Daemon框里,不需要什么json格式。如果想通过json文件修改,到C:\Users\用户名.docker\daemon.json文件修改链接数组

{
    "registry-mirrors": [
        "{http1}",
        "{http2}"
    ]
}

可能配置文件 windows下的配置文件目录为:C:\ProgramData\Docker\config\daemon.json

{"registry-mirrors":["自己的专属url"],"insecure-registries":[], "debug":true, "experimental": true}

测试加速器是否设置成功

docker info

内容:

Microsoft Windows [版本 10.0.17763.1098]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\yanzu>docker info
Client:
 Debug Mode: false
 Plugins:
  app: Docker Application (Docker Inc., v0.8.0)
  buildx: Build with BuildKit (Docker Inc., v0.3.1-tp-docker)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 13
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 958.5MiB
 Name: docker-desktop
 ID: BESO:RFBA:NVNO:QW7C:TKXP:SFMZ:SWJ7:FF4N:YQIX:4IQU:WX4K:GI3D
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 33
  Goroutines: 49
  System Time: 2020-04-15T15:29:24.284176831Z
  EventsListeners: 3
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors: #####看这里
  https://59jxl79g.mirror.aliyuncs.com/
  https://hub-mirror.c.163.com/
  https://reg-mirror.qiniu.com/
  https://registry.docker-cn.com/
 Live Restore Enabled: false
 Product License: Community Engine