Spring Boot Tutorial 34--docker Getting Started

Source: Internet
Author: User
Tags solr docker stop container docker ps docker hub rabbitmq docker run dynamodb gemfire

Spring Data Introduction
The Spring data project is a package of solutions that spring uses to solve data access problems. Spring data contains a large number of relational and non-relational database access solutions. Spring data enables us to quickly and simply use common data access technologies and new data access technologies.

Spring data contains the following sub-projects:
Spring Data JPA

Org.springframework.data
Spring-data-jpa
1.8.1.RELEASE

Spring Data MongoDB

Org.springframework.data
Spring-data-mongodb
1.7.1.RELEASE

Spring Data neo4j

Org.springframework.data
Spring-data-neo4j
3.3.1.RELEASE

Spring Data Redis

Org.springframework.data
Spring-data-redis
1.5.1.RELEASE

Spring Data SOLR

Org.springframework.data
Spring-data-solr
1.4.1.RELEASE

Spring Data Hadoop

Org.springframework.data
Spring-data-hadoop
2.2.0.RELEASE

Spring Data GemFire

Org.springframework.data
Spring-data-gemfire
1.6.1.RELEASE

Spring Data REST

Org.springframework.data
Spring-data-rest-webmvc
2.3.1.RELEASE

Spring Data JDBC Extensions

Org.springframework.data
Spring-data-oracle
1.1.0.RELEASE

Spring Data Couchbase

Org.springframework.data
Spring-data-couchbase
1.3.1.RELEASE

Spring Data Elasticsearch

Org.springframework.data
Spring-data-elasticsearch
1.2.1.RELEASE

Spring Data Cassandra

Org.springframework.data
Spring-data-cassandra
1.2.1.RELEASE

Spring Data DynamoDB

Opensourceagility-release
Http://repo.opensourceagility.com/release


Org.springframework.data
Spring-data-dynamodb
1.0.2.RELEASE

Spring data supports the use of a unified API to perform data access operations on these database technologies. This is spring by providing the Spring Data Commons project, which is dependent on the various spring data projects described above. Spring Data Commons allows us to use a unified spring-based standard when using relational or non-relational data access technologies that contain CRUD (create, Fetch, UPDATE, delete), query, sort, and paging related operations.

An important concept of Spring Data Commons is presented here: Spring Data repository abstraction. Using spring data repository can greatly reduce the code of the data access layer. Spring Data Repository Abstract root interface when Reposityory interface:

package org.springframework.data.repository;import java.io.Serializable;public interface Repository<T,ID extends Serializable>{}

As can be seen from the source code, it accepts the domain class (JPA is the entity Class) and the domain class ID type as the type parameter.
Its subinterface crudrepository defines content related to CRUD operations, and crudrepository sub-interface pagingandsortingrepository defines what is related to paging and sorting operations.

Different data access technologies also provide different repository, such as spring data JPA has jparepository, spring data MongoDB has mongorepository.

The Spring Data project gives us an exciting feature that allows you to count, delete, query, and so on, based on the attribute name. Such as:

public interface PersonRepository extends Repository<Person,Long>{    //按照年龄计数    Long countByAge(Integer age);    //按照名字删除    Long deleteByName(String name);    //按照名字查询    List<Person> findByName(String name);    //按照名字和地址查询    List<Person> findByNameAndAddress(String name,String address);}

Getting Started with Docker
Docker is a lightweight container technology, similar to virtual machine technology. Docker runs directly on top of the current operating system, rather than in virtual machines, but it also implements the resource isolation of virtual machine technology, which is much more performance than virtual machine technology.
Docker supports compiling the software into a single image (image), in this image to do a variety of software configuration, and then publish the image, the user can run this image, the running image is called a container, the start of the container is very fast (second level), a bit like ghost.
At present, major mainstream cloud computing platforms support Docker container technology, which is a trend of unified cloud computing.
Most of the current mainstream software and non-mainstream software is packaged as a docker image, we just need to download the Docker image and then run the image to quickly get the software that is ready to run.
In particular, Docker is not a gadget for developing testing convenience, but rather an excellent way to deploy in a real-world production environment.

Installation of 1.Docker

Install Docker under Mac, just install DOCKER.DMG.
After you start Docker, you can verify that the installation was successful by viewing the version in "Docker-v" on the command line.

2.Docker common commands and Parameters 1>. Docker Mirroring Command

Image retrieval
The Docker image is placed on the Docker hub of the https://registry.hub.docker.com, which is the address. You can search for images on the site, or use the command "Docker search image name" (e.g. Docker search Redis) to retrieve it.

Image download
Docker Pull Mirror Name

View the local mirror list
Docker images

Remove Mirror
Docker RMI Image-id

Remove all mirrors
Docker RMI $ (Docker images-q)

2>. Docker container Commands

Run image as container
Docker Run--name container-name-d image-name
Where the--name party committee container name,-d means detached, meaning that after executing this command console will not be blocked, you can continue to enter the command operation. Such as:
Docker Run--name test-redis-d Redis

View a list of containers in operation
Docker PS
Use the following commands to view the containers for the running and stopping states:
Docker Ps-a

Stop container
Stop a container by container name or container ID
Docker Stop Container-name/container-id
Such as:
Docker Stop Test-redis

Start container
To start a container by container name or container ID
Docker start Container-name/container-id
Such as:
Docker start Test-redis

Port mappings
The ports that are used by the software running in the Docker container need to be mapped to the port on the current host for access. Docker port mappings are implemented with a-p parameter. For example, we mapped the 6379 port of the Redis container to the 6378 port on this machine:
Docker run-d-P 6378:6379--name Port-redis Redis

Delete Container
Docker RM Container-id

Remove all containers
Docker RM $ (Docker ps-a-Q)

View current Container Log
Docker logs Container-name/container-id
Such as:
Docker logs Port-redis

Landing container
A running container is actually a fully functional Linux operating system, so we can log in and access the container like a regular system.
We can use the following command, log in to access the current container, after logging on we can do the regular Linux system Operation command in the container, you can also use the Exit command to exit the login:
Docker exec-it Container-id/container-name Bash

3. Download Common Docker images

Docker Pull wnameless/oracle-xe-11g
Docker pull Mongo
Docker Pull redis:2.8.21
Docker Pull Cloudesire/activemq
Docker Pull Rabbitmq
Docker Pull Rabbitmq:3-management

4. Exception Handling

If a command cannot be executed, log in to the VirtualBox virtual machine directly using the following command:
Boot2docker SSH
After you log on to the virtual machine, follow the general commands.

Spring Boot tutorial 34--docker Getting Started

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.