---
tags: advanced-networking
---
# Docker lab 6
## Install docker without using hyper-v.
Execute following commands in powershell Administrator mode to install [chocolatey](https://chocolatey.org/)
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
```
**Close** current powershell.
Execute following commands in powershell Administrator mode to install docker-cli and docker-machine.
```powershell
choco install docker-cli
choco install docker-machine
```
**Close** current powershell.
Create [virtualbox](https://www.virtualbox.org/) vm for docker in powershell. This vm requires **1 cpu** and **1 gb ram** only.
:::warning
You need to install virtualbox prior creating new virtualbox vm.
:::
### create virtualbox vm
```
docker-machine create --driver=virtualbox default
```
Check virtualbox docker-machine is up and running.
```
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v18.09.9
```
If your docker-machine has't started yet. Please start it by following command.
```
docker-machine start default
```
or
```
docker-machine restart default
```
Refer to [this](https://docs.docker.com/machine/drivers/virtualbox/) to know more about virtualbox docker-machine.
### load docker-machine
Load docker-machine to current in powershell when you start to use docker commands.
```
docker-machine env default | Invoke-Expression
```
Testing
```
docker info
docker version
docker ps
docker images
```
## Turn off virtualbox virtual network cards firewall
Win + R and type `wf.msc`.

## How to mount directories to docker container
before mount windows directeries to docker container, you have to create a sharing folder into virtualbox
for example: mount `d:\tmp`
1. stop virtualbox VM first
```
docker-machin stop default
```
2. create shared folder on virtualbox(default)
```
c:>\cd "c:\Program Files\Oracle\Virtualbox"
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe sharedfolder add default --name "d/tmp" --hostpath "\\?\d:\tmp" --automount
```
ssh into virtualbox
```
docker-machine start default
docker-machine ssh default
```
Now you are inside docker-machine
Verify your c: or d: drive with `mount | grep -E '^/c/|^/d/'` command and you probably should see like this.
```bash
/c/Users on /c/Users type vboxsf (rw,nodev,relatime)
/d/tmp on /d/tmp type vboxsf (rw,nodev,relatime)
```
Make sure that docker-machine is mapped into your docker-cli.
```
docker-machine env default | Invoke-Expression
```
Run a docker container to verify `d:/tmp` should contain some files.
```
docker run -v /d/tmp:/tmp -it --rm ubuntu:18.04 bash
```

## References
https://digitaldrummerj.me/docker-windows-mounting-directories/