First, about Docker
What is Docker? Docker is written in the go language and is an open-source application container engine. Enables developers to quickly package their applications and rely on packages into an encapsulated portable container image, and then publish them to any popular machine (Linux, WINDOWS,MAC, etc.), or virtualize them. Containers are completely independent of the sandbox mechanism, with no interface to each other. Multiple container can be run at the same time, independent of each other, for multi-environment system testing is very useful, but Docker application far more than this.
Second, installation
1. Windows 7 system is recommended to use Docker Toolbox installation, simple rude direct quick and easy!
Https://www.docker.com/products/docker-toolbox
Use Docker coumunity Edition under Windows 10 system
http://get.daocloud.io/#install-docker-for-mac-windows
Https://www.docker.com/community-edition#/windows
2. Since the current Win7 system is the majority, a direct introduction to Docker Toolbox:
Docker Toolbox is a toolset that mainly contains the following content:
1. Docker CLI client to run the Docker engine to create mirrors and containers
2, Docker machine. Lets you run the Docker Engine command on the Windows command line
3, Docker Compose. Used to run the Docker-compose command
4, Kitematic. This is the GUI version of Docker.
5, Docker QuickStart shell. This is a command-line environment with Docker already configured.
6, Oracle VM Virtualbox. Virtual machines
Because the Docker engine daemon uses the kernel of Linux, we are not able to run the Docker engine directly in Windows. Instead, you need to run Docker machine command Docker-machine to create and acquire a Linux virtual machine on your
Use this virtual machine to run the Docker engine on your Windows system
3. Preparatory work:
Windows 7 and x64, support for Hyper-V
4. Install Docker Toolbox
Install after download is complete
In this step, you will install Docker Toolbox. After installation, your system will install the following software:
1. Windows version of the Docker client
2. Docker Toolbox Management tool and ISO image
3. Oracle VM Virtualbox
4. Git msys-git Unix Tools
5. Confirm that the installation is successful
Once the installation is complete, you will see three new icons on your PC's desktop.
Double-click the Docker Quickstart Terminal icon to start a terminal
The first time you start, you'll see the command line output something, wait, it will configure Docker Toolbox, and then, when it's done, you'll see the boot success screen.
If there is no boot2docker image on the bash screen, you need to download it on GitHub, as follows
This is because the default Boot2docker image is not found because the prompt is downloading, but github download speed is not flattering, the first reaction is to find other station resources to download.
It is important to note that the different Docker versions are best matched to the same Boot2docker version, and it should be noted that the GitHub download page should be open. Finally I found that, in fact, do not download,
There is a boot2docker at the beginning of the installation of the Dockertoolbox root directory, and it can be inferred that it is the corresponding version.
Copy the Boot2docker.iso to the directory that bash is not looking for (I'm C:\Users\Administrator\.docker\machine\cache here).
Then double-click the Docker Quickstart Terminal icon again and the following interface appears, indicating that the installation was successful.
Enter Docker run Hello-world on the command line and press ENTER, if the Docker configuration succeeds, you will see the following output on the command line:
The Docker environment configuration is complete under Windows.
Third, build a simple webapp image with a nodejs environment
1. Nodejs environment is configured locally (refer to Nodejs website: https://nodejs.org/en/download/)
2. Go to express website to download generator
Reference step: http://expressjs.com/en/starter/generator.html
3. After installation in the corresponding Express application folder such as C:/MYSPP:
Create a new file Dockerfile, copy the following code
# Express-app
#
# VERSION 1.0.0
From Node:latest
RUN mkdir-p/home/www/express-app
Workdir/home/www/express-app
COPY. /home/www/express-app
RUN NPM Install
EXPOSE 3000
CMD ["NPM", "Start"]
Then double-click the desktop dockerquickstartterminal icon to enter the Dockerterminal interface:
Jump to the Express app file path you just installed: CD C:/myapp
Note that the slash in the file path in the Docker terminal is reversed , unlike a direct copy of the path, to be replaced by a backslash, or Docker will not jump.
Then enter: Docker build-t MyApp. (Note the following points)
The results of the operation are as follows:
Seeing successfully build * * * indicates that the image was built successfully.
Then verify that the image is already there: Docker images
The mirroring build process can be viewed through Dicker history: Docker
Then run the image: Docker run-p 3000:3000 MyApp
If you want to have the Docker terminal run in the background: add-D to the parameter
You can view the operation through Docker PS:
In the local browser input: 192.168.99.100:3000 View the running app: (note using Docker Toolbox instead of 127.0.0.1, but using the same IP address that was assigned when you started Docker)
To view Browser WebApp operation:
Steps and considerations for installing, build, and run under Docker windows