Reflections Windows10 installation of Docker

Recently a colleague used on windows7 / 10 docker encountered some problems to consult me, trying to help him after he also summed up the thinking, the share is now in the form of a blog.
Environment Description: windows10 Pro 64
a, Docker, there are two ways to deploy on Windows 10
1, install DockerToolbox, the method is to use VirtualBox creates a virtual machine named default linux, linux virtual machine again in the run up to docker.
2, the use of Windows Hyper-v virtualization technology, installed directly on a Windows docker (first open Hyper-v, but Hyper-v and vmware workstation are not compatible, the latter want to run vmware workstation will also be required to disable Hyper-v, so temporarily this method is not recommended). The shoes need to try download link ( https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe )

Second, the following describes only use DockerToolbox docker run on Windows 10
1, Docker Toolbox download link: https://dn-dao-github-mirror.daocloud.io/docker/toolbox/releases/download/v1.12.3/DockerToolbox-1.12 .3.exe
DokcerToolbox default integrated VirtualBox version may not work properly, it is possible to install the latest version of VirtualBox, you can uncheck VirtaulBox when you install DockerToolbox, shown in Figure 1.1.
Reflections Windows10 installation of Docker
Figure 1.1
Note: If you can not use the default VirtualBox, then download the latest VirtualBox (download link is: https://download.virtualbox.org/virtualbox/6.0.14/VirtualBox-6.0.14-133895-Win.exe), press the default settings to complete the installation .
2, after the completion of the installation DockerToolbox, double-click the desktop icon, in Figure 2.1, run Docker Quickstart Terminal, prompts C: \ Users \ $ {user } .docker \ machine \ cache \ boot2docker.iso low version, shown in Figure 2.2 to back (from the GitHub https://github.com/boot2docker/boot2docker/releases/download/v19.03.5/boot2docker.iso) download, copy the download address of the terminal would have a direct use Thunder download .
Reflections Windows10 installation of Docker
Figure 2.1
Reflections Windows10 installation of Docker
Figure 2.2
Also pay attention to things, VirtaulBox default default virtual machines and virtual disks are created in C: \ Users \ $ {user } .docker \ machine \ machines \ default. After mirroring and more containers, will lead to the C disk space is not enough, the virtual machine may refer to a directory other letter, only need to add environmental variables MACHINE_STORAGE_PATH, shown in Figure 2.3.
Reflections Windows10 installation of Docker
2.3
closing the terminal window in FIG. 2.2, After the download is complete, replace the direct copy D: \ virtual-box \ cache \ boot2docker.iso, then run Docker Quickstart Terminal Desktop icon, shown in Figure 2.4.
Reflections Windows10 installation of Docker
2.4 FIG.
3, to create the container test, Figure 2.5, Figure 2.6, 2.7 as shown in FIG.

$ docker pull centos
$ docker run -idt --name web01 -p 8088:80 --privileged=true centos:latest /sbin/init
$ docker exec -it web01 /bin/bash
[root@b95faf1d7801 /]# yum -y install httpd
[root@fe83f8d07d98 /]# systemctl enable httpd
[root@fe83f8d07d98 /]# systemctl start httpd
[root@fe83f8d07d98 /]# echo "hello world" >> /var/www/html/index.html

Reflections Windows10 installation of Docker
Figure 2.5
Reflections Windows10 installation of Docker
Figure 2.6
Reflections Windows10 installation of Docker
Figure 2.7
III Summary
1, by default after installing virtaul box runs a virtual machine (by boot2docker.iso guided LiveCD equivalent), to mount a virtual disk (/ dev / sda) on persistent storage docker windows containers and mirror, the virtual machine network is 192.168.99.0/24(config.json can be changed), if the first installation, the default IP is 192.168.99.100, login user name / password is docker / tcuser, the virtual machine has two purposes:
(1), all containers run on the virtual machine.
(2), iptables do DNAT publishing application port.

2, some of the problems encountered in the course description:
(1), the virtual machine will clean out every restart iptables configuration, docker and root user password will be reset to the default. So every time you shut down your computer, it is recommended to suspend (hang) in the virtual box in the virtual machine, the next day to run the virtual machine in VirtualBox to use when.
(2), the default port mapping is configured with default iptables virtual machine (ssh [email protected]) do DNAT release port on windows. After the container is created, if there are new services need to map the port again, you can log in directly to the default virtual machine increases mapping records, for example, execute the following command issued 8089 ports:
root@default:~# iptables -t nat -A DOCKER ! -i docker0 -p tcp -m tcp --dport 8089 -j DNAT --to-destination 172.17.0.2:80
To remove the mapping, execute the following command
root@default:~# iptables -t nat -L -n --line-numbers# list all nat rules
root@default:~# iptables -t nat -D DOCKER 8# by number delete rule, the rule number is deleted here 8
recommended method is to modify the mapping (the method is also suitable for Ubuntu / Centos host)
I), iptables-Save> iptbles
2), which modify iptables content, or delete Add rule
3), iptables-restore iptables
Note: the above operation is performed in the default virtual machine as the root user.
3, the use of container management experience Kitematic
(1), in Kitematic management menu items, each click save (save) operation will delete the original container to re-create a new container in the original container installed software and configurations will not be inherited in a new container. For example, using Kitematic to publish port, if the vessel is already in use at this time would like to publish the new port will use Kitematic result in total loss of the vessel data, including software environment installed! My posture is not operating? , Personally feel that this tool is only suitable for use when you first create a container (disposable and convenient search image settings on the docker Hub).

Guess you like

Origin blog.51cto.com/firefly222/2452644