Docker in Windows
Before going into this topic, you can find Docker and Kubernetes introduction here Docker & Kubernetes
Here I am going to talk about ‘docker in windows’, what is required for building a docker in windows, how to create image, build docker, what are all the supporting tools available in market, how to push the built container to docker orchestration( docker swarm and Kubernetes). I am not going to talk about installation steps or solution for solving the docker desktop installation, there are lot of other forums help you. I can provide solution to the docker create/ build problems.
Docker community provides Docker Desktop installer for Windows that you can get it from Docker Hub. You will get more detail about installation in docker docs. Docker desktop is purely for building the container, not for running the docker in cluster. For running docker in cluster either you should have docker swarm or Kubernetes.
Once you installed, you could see the docker icon in task bar. Right click menu of docker icon provides many options. To verify the Docker installation, try “docker info” command in windows-cmd. You can learn other docker commands using “docker help”.
There are problems when you build docker with npm commands in windows. This will be helpful whoever build a docker with node, react, angular projects in windows to resolve.
You can go to command prompt and use usual docker commands for building the containers as you use it in another OS. docker create , docker build are the commands for building containers.
Switch to Windows Containers Option:
While installing the Docker Desktop there is an option of choosing the Windows containers or Linux containers. You should consider the run time environment. if the built container is going to run on the windows cluster environment you can go with the “Windows container option” otherwise you should go with the “Linux Containers” option. If you forget to chose while installing, it can be done post installation through right-click menu.
What is the problem when you choose windows container while building and push to Linux environment cluster (for ex: K8)? you will have docker build problem, if there is a “npm install” command in your Docker file. You will get error, not be able to download some of the supporting libraries like below. Even you try to set up proxy or DNS those will not resolve your problem.
When you build docker, you should remove node modules folder, otherwise your docker file try build your project/application along with the node modules.
That is the bad practice for 2 reasons, one is that node modules folder has several libraries that will not help your container to be a light weight and second reason is that your local “node modules” would have been built with the help of your local OS (in this case windows) and your running environment might be not windows then you will get conflict issue.
In case, you don’t delete your “node modules” folder when you build a docker, you will have below error.
You should push your container to cluster to make it on cloud. You can push your container to any orchestrator (docker swarm/ Kubernetes) by using docker push command. When you want to push your container to K8 clusters, you should install kubctl or minikube. In case of kubectl, you will find kube config file in ~\.kube\config, you should add your own cluster before pushing the containers to K8.
You can use Kyma, SAP’s open source K8 cluster management tool to manage the container in K8.
Here you will find the solutions for various Docker build issues in Windows.