linux the docker

Brief introduction

Docker is an open source application container engine , based on the language go, follow the open source protocol from Apache2.0

Docker allows developers to package their applications and dependencies to a lightweight, portable container and then posted to any popular linux machine can be virtualized.

The container is full use of the sandbox mechanism will not have any interface with each other.

Three of the concept docker

Mirror:
     - understood as a system disk dvd image, lightweight image file

warehouse:
    - storage docker mirrored

container:
    - based on the Mirror operation, the container instance
Three concepts

Docker scenarios

1 local dependency.
     - Use docker, can save a lot of time .docker can improve the development efficiency of the developers, let us quickly build a development environment, development environment machine memory is usually relatively small, previously used virtual, it often needs to be development environment machine plus memory, and can easily make dozens of service by Docker Docker in the run up.

2 . Up the environment
      - It allows you to run the code on the environment and then deployed configuration, the same configuration can be used in Docker different environments, thus reducing the hardware requirements and the degree of coupling between the application environment

3 . Micro Services
      - Micro Services Architecture eleven one application into a single individual overall loosely coupled services you can configure each service is packaged as a docker mirror and use docker-. Compose to simulate the production environment (checkout docker networks) . The very beginning of the practice may be more time-consuming, but in the long term to eventually have a huge productivity.

4 . Automatic test
     - this does not mean in Docker run test cases, test cases but will run with mirrored closely together. There will be a big advantage when you write a test case for a docker image

5 deployment process.
     - Many mainstream hosting providers support the hosting docker, if you have a dedicated node has shell access / vm, then things will become easier. Only you need to set up docker, and you can run your image on the port you want.

6 . Continuous Deployment
     - say Docker natural fit for continuous integration / continuous deployment, use Docker in the deployment, the deployment will continue to be very simple and will start again after entering the new mirror. Kubernetes is a container cluster management system is an open source platform that can achieve the container cluster deployment automation, automatic scaling capacity, maintenance and other functions.

7 . Multi-tenant environments
     --Docker interesting use of a scene in a multi-tenant, it avoids rewriting critical applications. If you open the application services to multiple tenants (tenant refers to a group of users, such as tissue), using a single-tenant application program design if the use of the Domain +-Sub Docker can provide quick access to multi-tenant service.

8 from a machine and multiple App.
     - Ocker still be well managed all services on a single machine. You should use folders to retain data based docker image data for each mount.

9 . Expansion
     --Docker to help you by creating another container easily scale horizontally. If you encounter a huge peak traffic, Docker can help you solve the problem - simply add more machines and increase the number of containers running behind a load balancer.
Scenes

Docker's advantage

1 , a simplified procedure:
Docker allows developers to package their applications as well as a portable container to the dependencies, and then posted to any popular Linux machine, you can virtualize. 
Docker changed the way virtualization, enabling developers to put their results directly to the Docker for management. Convenient Docker already is the biggest advantage of, used to take days or even weeks with the task in handling Docker containers, only take seconds to complete.
2 , avoid selecting phobia If you have a choice phobia, or experienced patients. Docker help you pack your tangle! For example Docker mirror; Docker mirror configuration and includes the operating environment,
it is possible to simplify the deployment of multiple applications Docker working examples. Such as Web applications, back-end applications, database applications, large data applications such as Hadoop cluster, message queues, etc., can be packaged into a single image deployment.
3 , save money: On the one hand, the cloud computing era, so that developers do not have effect in order to pursue high configuration hardware, Docker changed the thinking of high-performance high price given the inevitable trend. Docker combined with cloud
to cloud space to be more fully utilized. Not only solved the problem of hardware management, but also changed the way of virtualization.

Docker installation

1. Install docker, due to the speed problem, select Ali cloud yum source download

yum install docker -y

2. Start docker

systemct1 start docker

3.docker accelerator, accelerate downloads

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
Docker will generate a configuration file, the path is /etc/docker/daemon.json

Configuring the accelerator need to restart docker

systemct1 restart docker

Docker learning basic commands

By
 # download image docker 
docker pull Hello- World
 # operation docker image generating container instance

# Run docker mirror, ubuntu system 
docker run ubuntu  

# Interactive operation ubuntu container into the container space 

Docker RUN Expediting IT ubuntu / bin / the bash 
     # of parameters 
    - I interactive command operation
     - T opening providing access to a terminal
     / bin / the bash shell interpreter specified
    
# Package to build a carry of vim centos image file 
    1 . First run a base image centos
    RUN Docker Expediting IT CentOS / bin / the bash 
     2 . In the space inside the container, mounting vim
    vim install yum - the y- 
     3 . Exit container space, submitting this container for the new image
    docker commit   1d5698b91178    yuchao163/s17centos-vim
    
    
# Export the local image file 
Docker the Save 0fc9d49cb739> / opt / s17centos.tar.gz
    
# Import image file,     
Docker Load </opt/s17centos.tar.gz
increase
# Delete container record

docker rm container id 

# Batch delete records container 
Docker Docker RM `PS - aq`

# Force the removal of all container records 

Docker RM -f `Docker PS - aq`

# Remove a mirror record

docker rmi image id 

# Batch delete image file 
docker rmi `docker images -aq`  
delete
change:

# Modify docker image name, tag tag name 
docker tag id mirror new tag name


check:

After running through the docker image, generated record container

# Poor command of the mirror to see docker

docker  image ls  
Images Docker    # is equivalent to the command to view mirror


# Container see what processes are running, 
Docker LS Container  
docker ps 

# Docker PS can only view the running container 
Docker PS - A view of all container records

# Docker container, must have the background programs running, otherwise the container exit

# Query image recording docker 

docker search centos
Change and check

 

Guess you like

Origin www.cnblogs.com/tianshuai1/p/11077910.html