Docker-based java Web Service Construction

Source: Internet
Author: User
Tags virtual environment docker registry

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 Docker

According 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 information
docker version
Get Image
docker pull ubuntu:latest
View local Images
docker images
View image running status
docker images ubuntu
Run shell bash in a container
docker run -i -t ubuntu /bin/bash
Stop container
docker stop
Download Image

Images 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 container

Add 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 container

After 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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.