是否可以在 Azure Windows Server DSVM 上创建自定义的基于 Linux 的 Docker 映像
Posted
技术标签:
【中文标题】是否可以在 Azure Windows Server DSVM 上创建自定义的基于 Linux 的 Docker 映像【英文标题】:Is it possible to create custom Linux-based Docker image on Azure Windows Server DSVM 【发布时间】:2020-07-13 07:56:39 【问题描述】:我在运行 Windows Server 2019 的开发测试实验室中使用 Azure DSVM。我正在尝试安装 Docker 并努力让我能够从 Azure ML 服务环境运行本地实验。
我想在 Docker 上构建一个定制的 Linux 容器——我相信通过阅读其他一些在线帖子在 Windows 上是可能的(由于各种原因,我不能使用 Linux 主机)。当我尝试创建包含WORKDIR ...
步骤的此类图像时,我收到“容器 ***** 在 CreateProcess 期间遇到错误:Windows 系统调用失败”错误。
我在 DSVM(标准 D2s_v3)上安装了 Docker,方法是在创建时添加“Docker”工件,然后运行以下命令来启用 Linux 容器:
$> Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
$> [Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
运行一个简单的 Linux 容器可以正常工作:
$> docker run --rm -it alpine:latest
/ # ls
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ #
为了构建自定义镜像,我使用了一个简单的 Dockerfile,如下所示:
FROM alpine:latest
WORKDIR /abm
图片成功出现在build
:
$> docker build --no-cache -t abm-alpine:workdir -f .\abm-alpine.Dockerfile .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine:latest
---> a187dde48cd2
Step 2/2 : WORKDIR /abm
---> 495f8ecb3a0e
Removing intermediate container 219e91296e47
Successfully built 495f8ecb3a0e
Successfully tagged abm-alpine:workdir
当我run
图片时,我收到以下错误:
$> docker run --rm -it abm-alpine:workdir
C:\Program Files\Docker\docker.exe: Error response from daemon: container 01fad57c971d672d91238a6c6ec21376e033006ec4c26563e91e7288cfb3bfeb encountered an error during CreateProcess: failure in a Windows system call: The virtual machine or container exited unexpectedly. (0xc0370106) extra info: "CommandArgs":["/bin/sh"],"WorkingDirectory":"/abm","Environment":"HOSTNAME":"01fad57c971d","PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","TERM":"xterm","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[50,120],"OCISpecification":"ociVersion":"1.0.0","process":"terminal":true,"consoleSize":"height":50,"width":120,"user":"uid":0,"gid":0,"args":["/bin/sh"],"env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","HOSTNAME=01fad57c971d","TERM=xterm"],"cwd":"/abm","capabilities":"bounding":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"effective":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"inheritable":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"permitted":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"root":"path":"rootfs","hostname":"01fad57c971d","mounts":["destination":"/proc","type":"proc","source":"proc","options":["nosuid","noexec","nodev"],"destination":"/dev","type":"tmpfs","source":"tmpfs","options":["nosuid","strictatime","mode=755","size=65536k"],"destination":"/dev/pts","type":"devpts","source":"devpts","options":["nosuid","noexec","newinstance","ptmxmode=0666","mode=0620","gid=5"],"destination":"/sys","type":"sysfs","source":"sysfs","options":["nosuid","noexec","nodev","ro"],"destination":"/sys/fs/cgroup","type":"cgroup","source":"cgroup","options":["ro","nosuid","noexec","nodev"],"destination":"/dev/mqueue","type":"mqueue","source":"mqueue","options":["nosuid","noexec","nodev"],"destination":"/dev/shm","type":"tmpfs","source":"shm","options":["nosuid","noexec","nodev","mode=1777"]],"linux":"resources":"devices":["allow":false,"access":"rwm","allow":true,"type":"c","major":1,"minor":5,"access":"rwm","allow":true,"type":"c","major":1,"minor":3,"access":"rwm","allow":true,"type":"c","major":1,"minor":9,"access":"rwm","allow":true,"type":"c","major":1,"minor":8,"access":"rwm","allow":true,"type":"c","major":5,"minor":0,"access":"rwm","allow":true,"type":"c","major":5,"minor":1,"access":"rwm","allow":false,"type":"c","major":10,"minor":229,"access":"rwm"],"namespaces":["type":"mount","type":"network","type":"uts","type":"pid","type":"ipc"],"maskedPaths":["/proc/kcore","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug"],"readonlyPaths":["/proc/asound","/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"],"windows":"layerFolders":["C:\\ProgramData\\docker\\lcow\\5ba6a7b4fbdf9748ec89898be9bdaa911ee614436a475945638ab296b1155966","C:\\ProgramData\\docker\\lcow\\01fad57c971d672d91238a6c6ec21376e033006ec4c26563e91e7288cfb3bfeb"],"hyperv":,"network":"endpointList":["D615E3D5-B6AA-401E-A0A0-72581FA47059"],"allowUnqualifiedDNSQuery":true.
我尝试了各种日志(例如Get-WinEvent -LogName Microsoft-Windows-Hyper-V-Compute-Operational
和Get-EventLog -LogName Application -Source Docker
),但看不到有关错误的任何其他信息。
谁能建议是否可以在 Windows DSVM 上创建基于 Linux 的自定义映像?如果是,谁能告诉我可能是什么问题或我可以采取的任何其他故障排除步骤?
谢谢!
【问题讨论】:
【参考方案1】:可以在 Windows Server 上创建 Linux 容器。
虽然目前处于实验阶段。
这篇文章可能会有所帮助:https://www.b2-4ac.com/lcow-linux-containers-on-windows-server/
【讨论】:
虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。以上是关于是否可以在 Azure Windows Server DSVM 上创建自定义的基于 Linux 的 Docker 映像的主要内容,如果未能解决你的问题,请参考以下文章
是否可以在 Azure Windows Server DSVM 上创建自定义的基于 Linux 的 Docker 映像
使用 Windows Azure 在 Android 上推送通知