简体   繁体   English

通过 powershell 脚本执行 docker run (Windows 10)

[英]Execute docker run through powershell script (Windows 10)

I have been searching for a way to execute a Docker run in a Powershell script, ie something in the lines off:我一直在寻找一种在 Powershell 脚本中执行 Docker 运行的方法,即行中的某些内容:

Start-Process ([docker.exe, “docker run -v … -t …”])启动进程([docker.exe,“docker run -v ... -t ...”])

The purposes of putting my Docker run in a Powershell script is so I can use the Windows 10 scheduler in order for it to run my container (having a Ubunutu 18.04 base images with a bunch of bash scripts) which will perform a set of infrastructure process tasks.将我的 Docker 放在 Powershell 脚本中运行的目的是,我可以使用 Windows 10 调度程序来运行我的容器(具有带有一堆 bash 脚本的 Ubunutu 18.04 基础映像),这将执行一组基础设施过程任务。

Can anyone point me in the right direction of getting this done?任何人都可以指出我完成这项工作的正确方向吗?

Sincerely, /swepab真诚的,/swepab

I solved this problem through executing a Python script in the following manner:我通过以下方式执行 Python 脚本解决了这个问题:

    import time
    import random
    import subprocess
    from pathlib import Path

    subprocess.call(["powershell.exe", "docker run -v 'mount path from my computer':'mounth path container' "dockerfile_ubuntu1804_windows10"])

I scheduled this and it works like a charm, running the image and building the container to execute the bash script I have made connected to the container.我安排了这个,它就像一个魅力,运行图像并构建容器来执行我连接到容器的 bash 脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM