Docker is a "PaaS" cloud that can run any application

Introduction to Docker

Docker  is an open source tool that can run any application in an "LXC container". If we say VMware, the virtual machine packaged by KVM, the application packaged by Docker. It is a well-deserved PaaS.

When the application is packaged as a Docker Image, deployment and operation and maintenance become extremely simple. Download, launch, extend, delete, migrate in a unified way  .

Docker is a "PaaS" cloud that can run any application

View larger image


Dock can be used to:

Automatically package and deploy any application Create a lightweight private PaaS cloud Build a development and test environment Deploy scalable web applications

Docker is open source and its code can be accessed on GitHub , providing a Restful interface. His contributor is a very popular PaaS cloud provider  https://dotcloud.com/

Core Values ​​of PaaS

Missing Direction - The vast majority of applications can't be seamlessly migrated to mainstream PaaS

Cloud computing has been developed for many years and is divided into IaaS, PaaS and SaaS. Among them, PaaS (Platform as a Service) is the least shy. The author is because the biggest reason is that PaaS does not bring enough value to people (development, operation and maintenance, boss), and the threshold for private PaaS is high! The biggest problem is that most applications cannot be seamlessly migrated to PaaS.

Heroku is the most popular public PaaS cloud. Very cheap and easy to use, but most applications cannot be deployed. Each application can only listen to one HTTP port, and applications cannot interact with each other. It can automatically scale and load balance for you, but you don't really have a choice, as long as you use Heroku you have to accept the limitations. Anyway, Heroku supports most platforms such as Java and Python. In contrast, GAE is even worse, only supports three platforms, cannot access the file system, and cannot start child processes.

CloudFoundry is the more popular private PaaS cloud. There are as many limitations as Heroku, and deployment is more complicated. He even has a tailored deployment tool BOSH for this purpose. How difficult it is to use, everyone who has used it knows. This can't be blamed on the developer, the PaaS he defines is so complicated.

PaaS should realize the dream of developers and operation and maintenance personnel - free operating environment, unlimited resources

Developers want to focus on program logic. There is a free running environment and abundant external resources such as various middleware. At least don't be bothered by the number of ports listening, the communication protocol limits these things.

Operation and maintenance people's dream - no failures and repetitions, reducing waiting

Operation and maintenance deal with faults every day. If thousands of applications can be deployed and maintained in the same way. Then the handling of faults is much simpler, and there will be fewer repetitions. Downloading and deploying, installing dependencies, these things are too cumbersome and time-consuming.

Docker features

Docker makes both development and operation easy.

Developers do not need to develop applications under the conditions full of restrictions like using general PaaS, and can use various resources freely as usual. Lao Tzu said, "The superior and the inferior know it, then praise it, and then insult it." Dock is a state of "understanding" for developers.

The cool person is the operation and maintenance. To use Docker, Docker Engine needs to be installed on the machine,

Create a Container. In fact, it is a Linux Container, and Docker will configure the network and storage. Download the app and install it. For example, you can use sudo apt-get install mysql-server to install a MySQL. And configure some parameters or something. Package and upload the Image. Docker can package this Linux Container into an Image, and the startup script is also included. And upload to Image Registry. This Image only includes the incremental part you modified , so the volume is relatively small. A command runs. Use the Docker Run command to download an Image from the Image Registry and run it.

Docker is a "PaaS" cloud that can run any application

View larger image



When a restart is required, just restart the Container. When you need to migrate, just migrate the Container. Everything was clean.

PaaS, IaaS technology industry has specialization

IaaS generally uses virtual machines, which are expensive. Docker is significantly lighter. The author believes that IaaS and PaaS have their own specialties. It is meaningless for PaaS to focus on the isolation of security levels, and IaaS should not perceive applications. In a public cloud, each tenant can use different virtual machines and virtual networks to achieve security and resource isolation. Then through the unified operation and maintenance of PaaS, the computing resources are managed.


Docker is a "PaaS" cloud that can run any application

View larger image


There is no need to dedicate a virtual machine to each application, which is too expensive. But in security-sensitive environments, it makes sense to use a different virtual machine for each tenant.

Use Docker

try it online

The easiest way to use Docker is  to try it onlinehttp://www.docker.io/gettingstarted/#

After completing this online textbook, I believe you have basically played with Docker.

Install Docker in Ubuntu

Docker now supports two Ubuntu versions:

Ubuntu Precise 12.04 (LTS) (64-bit)Ubuntu Raring 13.04 (64 bit)

There are two dependencies

Linux kernel 3.8 (read more about  Kernel Requirements )AUFS file system

So you need to confirm your operating system, install dependencies and restart:

# Add the PPA sources to your apt sources list.

sudo apt-get install python-software-properties && sudo add-apt-repository ppa:dotcloud/lxc-docker

 

# Update your sources

sudo apt-get update

 

# Install, you will see another warning that the package cannot be authenticated. Confirm install.

sudo apt-get install lxc-docker

Install Docker and restart:

# Add the PPA sources to your apt sources list.

sudo apt-get install python-software-properties && sudo add-apt-repository ppa:dotcloud/lxc-docker

 

# Update your sources

sudo apt-get update

 

# Install, you will see another warning that the package cannot be authenticated. Confirm install.

sudo apt-get install lxc-docker

Using Docker, download an Ubuntu Image and create a Container in which to run Bash

# download the base 'ubuntu' container and run bash inside it while setting up an interactive shell

sudo docker run -i -t ubuntu /bin/bash

 

# type 'exit' to exit

Success, you've played around with Docker! !

What happened to Docker Run?

When the user executes Docker run, these things happen:

Docker CLI calls Docker Engine's Restful API. By default, Docker Engine listens on a Unix Socket, and of course it can also listen on a TCP port. Download an Ubuntu Image from the docker index . The docker index is a place to gather Docker Images, just like a Repository. You can also build your own private Repository. Allocate the file system. The file system is AUFS, which is an "incremental file system", where changes you make can be saved incrementally. So Docker Image can be small. Mount filesystems create network ports. Docker uses Linux Bridge and Linux Network NameSpace to configure networking. Configure the IP address. Assign an internal IP to the virtual NIC you just created. This IP is not important because Docker reserves the TCP/UDP port through static NAT. Execute commands in LXC. In this example, the command is "/bin/bash" to intercept the input and output streams of "/bin/bash" to Terminal, and interact with you in the Dock. Run Redis in Docker

Create a Docker Container

sudo docker run -i -t ubuntu /bin/bash

Install Redis.

apt-get update

apt-get install redis-server

exit

Take a snapshot and create your own Docker Redis Image

docker ps -a  # grab the container id (this will be the first one in the list)

docker commit <container_id> <your username>/redis

Run Redis. -d means run in the background, using the Image you just created.

sudo docker run -d -p 6379 <your username>/redis /usr/bin/redis-server

Access using redis-cli

sudo docker ps  # grab the new container id

sudo docker inspect <container_id>    # grab the ipaddress of the container

redis-cli -h <ipaddress> -p 6379

redis 10.0.3.32:6379> set docker awesome

OK

redis 10.0.3.32:6379> get docker

"awesome"

redis 10.0.3.32:6379> exit

 

 File system

In general, two file systems are required for Linux

boot file system (bootfs)root file system (rootfs)

bootfs contains the bootloader. Users never change bootfs. In fact, when the machine is finished booting, the kernel will unmount the bootfs.

rootfs is the directory where we usually see Linux files, including /dev, /proc, /bin, /etc, /lib, /usr, and /tmp, etc. The rootfs of different Linux distributions are different, and the package structure is also different. Docker can run multiple Linux distributions at the same time by managing rootfs.

Docker is a "PaaS" cloud that can run any application

View larger image


When traditional Linux starts, rootfs is read-only, and it will be converted into a readable and writable state after checking the integrity.

When Docker mounts rootfs, it is also read-only. But he did not turn it into a readable and writable state, and used  union mount  to add a layer on it to create a readable and writable file system. The principle rootfs is still read-only, and the data is written to the new space. Docker calls this "layers", where data can be layered on top of each other.


Initially, there is no data at the top level. When the process creates and modifies the file, the data will be stored at the top level. The underlying filesystem has not changed in the slightest.

When exporting Image, it is actually exporting the topmost layer.

Due to the underlying read-only, multiple Docker Containers can be shared, improving the efficiency of file system usage.

Docker Ecosystem

Docker is a "PaaS" cloud that can run any application

View larger image

Docker is open source, provides a complete Restful interface, has a simple design, and directly addresses pain points. However, it is relatively simple and has no fancy functions. Fengqi Wutong, with Docker as the trunk, has derived many excellent projects.

dokku  Micro-Heroku for 100-line BASH. It includes a basic PaaS function Shipyard  Docker management interface, providing functions such as multi-Host, creating Container, viewing Image, etc. openstack-docker  Docker and OpenStack integration, you can use Nova and Glance to control jiffylab Teaching Python and Unix Shell platform BYO SAAS  Memcached as a Service Dockerui  Docker management interface

Docker is a "PaaS" cloud that can run any application

View larger image


dokku

Docker is a "PaaS" cloud that can run any application

View larger image


{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324036761&siteId=291194637