Installing Docker on Windows
Published: 2022-05-19 03:27:42

_**Docker CE vs Docker EE**_
Docker CE is Community Edition which is free but EE is Enterprise Edition which is not free. In EE , you get support and more products.

Checkout the pricing: https://www.docker.com/pricing/

**_Installing Docker_**

If you don't already have Docker installed, Docker already has some great [guides](https://docs.docker.com/get-docker/) on how to do it, but if you already know which OS you want to install on, below are quicker steps for downloading it. The videos after this Lecture are walkthroughs of installing Docker for each OS, then getting the GitHub repo, getting a code editor, and tweaking the command line if you want to. Feel free to skip any of this Section if you have Docker Desktop and Visual Studio Code installed.


I always recommend Visual Studio Code (vscode) as your editor for all things Docker, Kubernetes, and DevOps. It's free for all OSs and has plugins to help you with many tools in this course.



_Installing on Windows 10 and Windows 11 (any Edition)_

https://docs.docker.com/desktop/windows/install/

This is the best experience on Windows, which uses [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install). If you're new to WSL2, it's the best way to run Linux on Windows, and Docker Desktop will walk you through enabling it. Docker can technically still work on Hyper-V with "Windows Containers", but most of this course focuses on Linux Containers, which WSL2 is great at.

After installing [Docker Desktop for Windows](https://docs.docker.com/desktop/windows/install/). I recommend installing a Windows Store [Ubuntu for WSL2](https://www.microsoft.com/en-us/p/ubuntu/9pdxgncfsczv?rtc=1&activetab=pivot:overviewtab) distro and using its shell in [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701#activetab=pivot:overviewtab) is the best CLI experience! Make sure to check your Docker Desktop settings to give it enough resources and enable all your WSL2 distros for Docker Desktop.

_Installing on Windows 7 or Windows 8_

Unfortunately, Microsoft's OS features for Docker Desktop don't work in these older versions. You'll need to use Hyper-V or install VirtualBox and manually setup a Linux VM. It's more involved than the other options, so I often recommend the easier option: using a DigitalOcean cloud server with my coupon code https://m.do.co/c/b813dfcad8d4 gets you $100 in credits over 60 days.


_Installing on Mac_

https://docs.docker.com/desktop/mac/install/

You'll want to install [Docker Desktop for Mac](https://docs.docker.com/desktop/mac/install/), which is great.


_Installing on Linux_

https://docs.docker.com/engine/install/

Do *not* use your built-in default packages like `apt/yum install docker.io`  because those packages are old and not the Official Docker-Built packages. 

I prefer to use [Docker's automated script](https://get.docker.com/) to add their repository and install all dependencies: `curl -sSL https://get.docker.com/ | sh`  but you can also install in a more manual method by following specific instructions that Docker provides for your [Linux distribution](https://docs.docker.com/engine/install/).

_Use Play With Docker_

https://labs.play-with-docker.com/

Maybe you don't have local admin, or maybe your machine doesn't have enough resources. Well, the best free option here is to use [play-with-docker.com](http://play-with-docker.com/), which will run one or more Docker instances inside your browser, and give you a terminal to use it with. You can create multiple machines on it, and even use the URL to share the session with others in a sort of collaborative experience.  I highly recommend you check it out.  Most of the lectures in this course can be used with "PWD", but the big limitation is it'll reset after 4 hours, at which time it'll delete your servers.


_Use DigitalOcean_

If you signup for a new account with DigitalOcean, my favorite "simpler" cloud, you can use a smaller server for months with my signup credit. Install Docker in the Cloud, via the above Linux links, and do the course without needing Docker locally. Thousands of students have done this: 

https://m.do.co/c/b813dfcad8d4 gets you $100 in credits over 60 days


**_Check your docker version_**
Let' check our docker version

```
docker version
```

Also check some information:

```
docker info
```
You may also see all the commands of docker:

```
docker
```
Also, we need to know the formats because there are actually lots of commands:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bqy14yfro4c9tdt6nsr.png)
 
**_Image vs Container_**
1. Image is binaries of applications

2. Container means the  running image

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7i3swyic79tr7rakbfx.png)

Let's run a container:

```
docker container run --publish 80:80 nginx
```
You can see what actually happened:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17ccmosb2i1t710sl7rn.png)

Now go to your browser and type `localhost`
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6rl30z7vzkw8aoknxbr5.png)
You can see something like this.
Also, open the docker hub and you can see something like this

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pb1iu1hvx5blkx8a3pe4.png)
  
 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pvs0xrwbzvvhhxehktqe.png)
Press  Ctrl + C to stop the container.
Also type ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okhooqwanrqbkvncqyq7.png)
to see the unique container ID which is still there . Now go to browser and you will still see the nginx website.
Now type 

```
docker container ls
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n2d77z15oiojh7o9vn7k.png)
You will see the containers still running and you will notice that this container id is same as we saw from the last command. 
Now lets stop it

```
docker container stop <1st few digits of the id>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9atfg4db6j4mqk4rj543.png)
 
now check the containers

```
docker container ls
```
You will find nothing.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddrdihmbm6spgf05o9wy.png)
Now, lets run:

```
docker container ls -a 
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jolxg9ug9jiw5yui1fqa.png)

Also into the docker desktop, you will find this

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xbsrn1i5jvgqih0rwmiw.png)
 
Now, you will find 2 containers. Why?
Because

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgkw3b4nv2yc8fsvib58.png)
We have used the command `docker container run` twice . Each time we run that command, it creates a container from the image (nginx) .
Also, you can see Container name which we never set but docker did by itself. Now, lets set that and create a new container 

```
docker container run --publish 80:80 --detach --name  mitulhost nginx
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7emihef2wtjq8pybwn9.png)
Now, lets see the container list again

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqk7l1r3e4dyjfz4ftjm.png)
Now, lets go to the localhost and refresh it to generate some logs . Then go to the terminal and them type

```
docker container logs mitulhost
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9mg1s7cexiyjw0spbxi.png)
Now, lets delete our containers

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rx37n3vibiaqm0w14zke.png)
To remove a container , we nee to type:

```
docker container rm <1st few digits of container  1> <1st few digits of container 2> ...
```
But this only works for the stopped container. As, we have "mitulhost" container already  running, we can stop it and run it.Or,else we can force it to be removed.

```
docker container rm -f <1st few digits of container
```
Let's see if we have  any containers left
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ekel9a5nw98qhp7la85q.png)
Nothing!!!


<img src="https://c.tenor.com/Tvd3VKwtse0AAAAC/cat-cute.gif">