简体   繁体   English

如何在 windows 中创建 Docker 容器以在 ubuntu vm 中运行

[英]How to create Docker container in windows to run in ubuntu vm

I have three small Springboot Microservices and a plan.我有三个小的 Springboot 微服务和一个计划。 I have to say that I develop in Eclipse under Windows10 Home.不得不说我是在Windows10 Home下的Eclipse开发的。

My plan is to build a Docker container of each one and run it in a ubuntu VM on my Windows pc, so that I can use the containers in a real linux server in the future. My plan is to build a Docker container of each one and run it in a ubuntu VM on my Windows pc, so that I can use the containers in a real linux server in the future.

Does this work?这行得通吗? What do I need?我需要什么? Is there a Docker for Windows that builds container for linux?是否有用于 Windows 的 Docker 为 linux 构建容器? How do I deploy the container to the vm?如何将容器部署到虚拟机? Do I have to push it to dockerhub first?我必须先将其推送到 dockerhub 吗? Can I access the container from a Windows Browser by some kind of port forwarding?我可以通过某种端口转发从 Windows 浏览器访问容器吗?

Thank you for your help....every hint is welcome.谢谢你的帮助....欢迎每一个提示。

You can use Docker for Desktop Windows with WSL 2 running a Ubuntu distro.您可以将 Docker 用于桌面 Windows 和运行 Ubuntu 发行版的 WSL 2。 It's the best setup to develop Docker for Linux, because of the incredible interoperability:这是为 Linux 开发 Docker 的最佳设置,因为具有令人难以置信的互操作性:

  • Both OS run side by side, sharing the same Docker environment (images, containers, compose sets, etc).两个操作系统并行运行,共享相同的 Docker 环境(图像、容器、组合集等)。 You can manage, configure using Docker tools on either OS, switching back and forth easily您可以在任一操作系统上使用 Docker 工具进行管理、配置,轻松来回切换
  • Both OS share the same file system, so you can develop config files with your favorite Windows editor which are equally accessible from Linux两个操作系统共享相同的文件系统,因此您可以使用您最喜欢的 Windows 编辑器开发配置文件,这些编辑器同样可以从 Linux 访问
  • Both OS share the same network, so you can access services, API from one to another via port forwarding (using browser in Windows and Curl in Linux to access same resources) Both OS share the same network, so you can access services, API from one to another via port forwarding (using browser in Windows and Curl in Linux to access same resources)
  • The close interoperability means no need to deploy across systems, since you have only one shared environment.紧密的互操作性意味着无需跨系统部署,因为您只有一个共享环境。
  • Since you develop in one place locally, no need to distribute images to remote repositories由于您在本地一个地方开发,因此无需将图像分发到远程存储库
  • As a bonus, Docker for Desktop ships with a fully working single cluster version of Kubernetes providing the same shared environment作为奖励,用于桌面的 Docker 附带一个完整工作的 Kubernetes 单集群版本,提供相同的共享环境

Go for it then, unless your machine has limitations against WSL. Go 然后,除非您的机器对 WSL 有限制。

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

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