Docker - Installation for Windows 7 (Docker Toolbox)

About

How I have installed and configured Docker in my Windows 7 laptop. The software for windows 7 is called Docker Toolbox.

Steps

Install Toolbox (for version before Windows 10)

Before version Windows 10: Toolbox:

_

Toolbox Components:

Create an host

I don't remember if it's necessary.

docker-machine create ^
    --driver virtualbox ^
    --virtualbox-memory 8192 ^
    --virtualbox-disk-size "40960"  ^
    default
Running pre-create checks...
(test) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(test) Latest release for github.com/boot2docker/boot2docker is v17.09.1-ce
(test) Downloading C:\Users\gerard\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.09.1-ce/boot2docker.iso...
(test) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(test) Copying C:\Users\gerard\.docker\machine\cache\boot2docker.iso to C:\Users\gerard\.docker\machine\machines\test\boot2docker.iso...
(test) Creating VirtualBox VM...
(test) Creating SSH key...
(test) Starting the VM...
(test) Check network to re-create if needed...
(test) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\DockerToolbox\docker-machine.exe env default

The machine runs on the boot2docker operating system

Environment

Variable

docker-machine env
You can further specify your shell with either 'cmd' or 'powershell' with the --shell flag.

SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\gerard\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
SET COMPOSE_CONVERT_WINDOWS_PATHS=true
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('"C:\DockerToolbox\docker-machine.exe" env') DO @%i
  • Create them:
    • Windows Key > Env > Env for your account

_

  • Add the 4 env variables

_

Host

Add a docker host in your host file with the host ip

  • Obtain the IP
docker-machine ip
192.168.99.100
  • Open an editor as Adminsitrator and add it to the host file C:\Windows\System32\drivers\etc\hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# ...........................
192.168.99.100   docker-host

SSH - Winscp

Create a new connection with the following parameters:

You should be able to see the c and d drive:

_

Shared Drive

When mounting a volume with the bind method, your local drive must be made available to the host (in all case on Windows 7 with Toolbox). The steps are well explained also in the VirtualBox Doc on shared folder.

Without following this steps, you can get this kind of issue: Bind mount issue on Docker for Windows)

Step 0 - The default shared folder

By default, you will see already a shared drive with:

  • the folder path \\?\c:\Users
  • the name c/Users
  • auto-mount checked
  • Make permanent checked

It means that the path c:\\Users is already shared.

_

If you put your files under this directory, you are done. If not, you need to follow the below steps.

Step 1 - Create the shared folder in Virtual Box

  • Manually create a Machine Folder share.

_

  • or with a script
VBoxManage sharedfolder add "default" --name "c" --hostpath "C:\"
VBoxManage sharedfolder add "default" --name "d" --hostpath "D:\"

where:

  • c is a name (not a path)
  • automatic mount means that the folders are mounted into the /media directory, along with the prefix sf_ (No thanks).
  • Access = Full means read and write.

For info: There are two types of shares:

  • Machine Folder are only available to the VM for which they have been defined;
  • Transient Folder can be added and removed at runtime and do not persist after a VM has stopped

Step 2 - Mount the shared folder in the docker host

docker-machine ssh 
# docker-machine ssh machineName
sudo su -
  • Create a file bootlocal.sh in your home and add the following line of code
# C
mkdir /c
mount -t vboxsf c /c

# D
mkdir /d
mount -t vboxsf d /d
  • Execute it
chmod u+x o+x g+x bootlocal.sh 
cd /home/docker
./bootlocal.sh 

Step 3 - Make the mount automatic

  • To mount a shared folder during boot, copy the file as root to the directory /var/lib/boot2docker/
sudo su -
cp /home/docker/bootlocal.sh /var/lib/boot2docker/

source local customisation with persistent-partition


Powered by ComboStrap