Docker-based java Web Service Construction
GuideRecently, I want to update and maintain our applications. Android, IOS, and servers are all busy writing code and writing articles. Our server uses the java ssh architecture, and we plan to switch to Spring MVC + oau2. if we are free today, let's take a look at the previous server environment.
1. Docker is a service software based on the application layer. Currently, it is used to build servers for development. It cannot be used to learn android/IOS development, of course, it cannot be ruled out that it can be used on a mobile phone in the future, so you have to learn it.
2. docker is a software. Through Docker, we can run different container environments, just like normal virtual machines, such as vmware and virtual box, we can install it on the operating system, and then we can build different operating systems. Now that we have virtual machine software, why should we use docker? There are many reasons. For developers, our answer is basically unified. I can quickly build a production environment on the server and quickly copy it to other servers. I drew out the Docker principles.
3. Docker extends the Linux container (Linux Containers), while LXC provides a set of unified APIs and tools to establish and manage the container, in this way, Docker can use these advanced APIs to provide a lightweight virtual environment. A Docker container does not occupy a single operating system as a virtual machine, but runs based on the functions provided by the operating system in the existing infrastructure. For example, there are 100 containers, they use the kernel of the same operating system. The following describes how to install the environment.
Install DockerAccording to the analysis just now, the software is actually installed. Because different operating systems may be a little different, you can find the information on your own. I have a Ubuntu system, right, note that the Linux operating system must be 64-bit. Note that Docker must be installed in Linux Kernel 3.8 or later.
$ sudo apt-get update$ sudo apt-get install docker.io$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker$ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
Docker commandsView version informationdocker version
Get Imagedocker pull ubuntu:latest
View local Imagesdocker images
View image running statusdocker images ubuntu
Run shell bash in a containerdocker run -i -t ubuntu /bin/bash
Stop containerdocker stop
Download ImageImages can be viewed on the official website.
https://hub.docker.com/explore/
I will use ubuntu as an example:
- Pull indicates download,
- Ubuntu indicates an image,
- ": Latest" indicates the last version, which is actually the latest version.
docker pull ubuntu:latest
I have to say that the download process is very slow and sometimes cannot be downloaded. It took me one afternoon to get it done. The solution is to create a private library. The specific docker registry URL:
https://github.com/docker/docker-registry
I will not introduce it here for the time being. You can study it on your own. After installing it, enter:
docker images
You can see whether the download has been made to the local device, as shown in figure
Start containerAdd shell and enter the following command:
docker run -i -t ubuntu:latest /bin/bash
Now we can see that the console has changed to the container command line. In this way, we can install our environment.
Docker ps-a # list all containers, including exited
Exit containerAfter entering the container, all operations in the container are new operations. We need to exit and enter exit directly.
From: http://www.toutiao.com/i6284104133792236033/
Address: http://www.linuxprobe.com/docker-java-web.html