简体   繁体   中英

How to create Docker container in windows to run in ubuntu vm

I have three small Springboot Microservices and a plan. I have to say that I develop in Eclipse under Windows10 Home.

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? How do I deploy the container to the vm? Do I have to push it to dockerhub first? Can I access the container from a Windows Browser by some kind of port forwarding?

Thank you for your help....every hint is welcome.

You can use Docker for Desktop Windows with WSL 2 running a Ubuntu distro. It's the best setup to develop Docker for Linux, because of the incredible interoperability:

  • Both OS run side by side, sharing the same Docker environment (images, containers, compose sets, etc). You can manage, configure using Docker tools on either OS, switching back and forth easily
  • Both OS share the same file system, so you can develop config files with your favorite Windows editor which are equally accessible from 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)
  • 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

Go for it then, unless your machine has limitations against WSL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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