1.Docker Introduction
Docker is an open source tool that you can use to wrap any app in the LXC container. If you say VMWARE,KVM packaged virtual machines, the Docker wrapper is the app. is a worthy PAAs.
When the app is packaged into Docker image, deployment and operations become extremely simple. Can be used in a unified way to download, launch, expand, Delete, migrate.
The dock can be used to:
- Automate packaging and deploying any application
- Create a lightweight private PAAs cloud
- Build Development test environment
- Deploy a scalable web App
Docker is open source and can be petitioned on GitHub to ask for its code, providing a restful interface. His contributor is a very popular PAAs cloud provider https://dotcloud.com/
The core value of PaaS
Lost Direction-most applications cannot seamlessly migrate to mainstream PAAs
Cloud computing has evolved over the years and is divided into Iaas,paas and SaaS. PAAs (Platform as a service) is the most get mad bland. The author because, the biggest reason is the PAAs to people (development, operation and maintenance, boss) brought not enough value, private PAAs high threshold! The biggest problem is that most applications don't seamlessly migrate to PAAs.
Heroku is the most popular public PAAs cloud. It's cheap and easy to use, but most apps can't be deployed. Each app can listen to only one HTTP port, and the app cannot interact with each other. He can auto-scale and load-balance for you, but in fact there is no choice, as long as the use of Heroku must accept the restrictions. At least Heroku supports most platforms such as Java,python. In contrast, Gae is even more capable of supporting only three platforms, no access to the file system, and no process to start a subprocess.
Cloudfoundry is the more popular private PAAs cloud. Restrictions are as much as Heroku, and deployment is more complex. For this he even has a tailor-made deployment tool bosh. How hard it is to use, everyone knows. This cannot be blamed on developers, and the PAAs he defines is inherently complex.
PAAs to realize the dream of the developers and the Ops people
Developing People's Dreams – free running environment, unlimited resources
Developers want to focus on the logic of their program. Have a free running environment, rich in external resources such as a variety of middleware. At least not why the number of port listens, the communication protocol limits these things to bother.
The dream of the OPS-no trouble and repetition, less waiting
Operation and maintenance of fault handling every day, if the thousands application can be deployed in the same way, operation and maintenance. Then the processing of the fault is much simpler, and the duplication of things will become less. Download deployment, installation dependencies, these things are too cumbersome and time-consuming.
Docker features
Docker makes development and operations easier.
Developers do not have to develop applications under restrictive conditions as with general PAAs, and are free to use resources as usual. Lao Tzu said, "Too much to know, second reputation, followed by insulted." The dock is a "know-it" state for developers.
The cool man is yun-dimensional. To use Docker, you need to install the Docker Engine on your machine,
- Create a container. Actually a Linux container,docker will put the network, store these things well.
- Download the app and install it. For example, you can install a MySQL by using sudo apt-get the install Mysql-server. and configure some parameters or something.
- Package upload image. Docker can package this Linux container as an image, and the startup script is in it. and upload it to the image registry. This image only includes the incremental part you modified, so the volume is smaller.
- A command to run up. Use the Docker Run command to download an image from image registry and run.
A reboot is required, as long as the container is restarted. When migration is required, just migrate container. Everything is clean.
Paas,iaas is specialized in the operation of the industry
IaaS generally uses virtual machines, which are expensive. Docker is noticeably lighter. I think that IaaS and PAAs are specialized, PAAs to focus on security level of isolation is meaningless, IaaS should not be aware of the application. In a public cloud, you can allow each tenant to use a different virtual machine, a virtual network for security and resource isolation. Then unify operation and maintenance through PAAs and manage computing resources.
There is no need for each app to have a single virtual machine, which is too expensive. In a security-sensitive environment, however, it is reasonable for each tenant to use a different virtual machine.
Use Docker to try Online
The easiest way to use Docker is to try it online: http://www.docker.io/gettingstarted/#
Complete this online textbook, I believe you have a basic play to Docker.
Installing Docker in Ubuntu
Now Docker supports two versions of Ubuntu:
- Ubuntu precise 12.04 (LTS) (64-bit)
- Ubuntu Raring 13.04 (+ bit)
There are two dependent
- Linux Kernel 3.8 (read more about kernel Requirements)
- AUFS File System
So you need to confirm your operating system, install dependencies and reboot:
- # 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'll see another warning so 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'll see another warning so the package cannot be authenticated. Confirm install.
- sudo apt-get install Lxc-docker
Use Docker to download an Ubuntu Image and create a container that runs bash in it
- # 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 been playing with Docker!!
What happened to Docker run?
These things happen when the user executes the Docker run:
- The Docker CLI invokes the restful API of Docker engine. By default, the Docker engine listens on a UNIX socket and, of course, it can listen on the TCP port.
- Download an Ubuntu Image from Docker index . Docker Index is a place that gathers the Docker image, just like a repository. You can also build your own private repository.
- Assign the file system. The file system is AUFS, which is a "Delta file system", and the changes you make can be saved incrementally. So Docker image can be very small.
- Mount File System
- Create a network port. Docker configures the network using Linux Bridge and the Linux network namespace.
- Configure the IP address. Match the virtual NIC you just created with an internal IP. This IP is not important because Docker retains the TCP/UDP port externally through static NAT.
- Execute the command in LXC, in this case the command is "/bin/bash"
- Intercept "/bin/bash" input and output streams to terminal, interacting with you
Dock details running Redis in Docker
Create a Docker Container
- sudo docker run-i-T Ubuntu/bin/bash
Copy Code
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 is the first one in the list)
- Docker commit <container_id> <your Username>/redis
Run Redis. -D refers to running 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, Linux requires two file systems
- Boot file system (BOOTFS)
- Root file System (ROOTFS)
Bootfs contains a bootloader. The user never changes the bootfs. In fact, kernel will unload the BOOTFS when the machine starts to finish.
Rootfs is where we usually see the Linux files directory, including/dev,/proc,/bin,/etc,/lib,/usr, and/tmp, and so on. Different Linux distributions are Rootfs, and the package structure is different. Docker manages ROOTFS to run multiple Linux distributions at the same time.
When traditional Linux is started, Rootfs is read-only and the integrity of the check is translated into a read-write state.
When Docker mounts Rootfs, it is also read-only. But he did not turn it into a read-write state, and on it it uses union Mount to add a layer to create a read-write file system. The rootfs of the principle is still read-only and the data is written into the new space. Docker calls it a "layer" where data can be superimposed on layers.
At first, there was no data in the topmost layer, and when the process created the modified file, the data was saved at the top level. The underlying file system has not changed in the slightest.
When you export an image, it is actually the top-most layer of the export.
Because of the underlying read-only, multiple Docker container can be shared, improving the efficiency of file system usage.
Docker Eco-Environment
Docker is open source, provides a perfect restful interface, simple design, straight poke pain point. However, it is relatively simple and does not have a gorgeous function. Fengqi Indus, with Docker as the trunk, derived many excellent projects.
- Dokku 100-line Bash's micro-heroku. Contains the basic functionality of a PAAs
- Shipyard Docker management interface, multi-host, create container, view image and other functions
- Openstack-docker Docker and OpenStack integration, you can use Nova and glance to control
- Python and Unix shell platform for Jiffylab Teaching
- BYO SAAS Memcached as a Service
- Dockerui Docker Management Interface
<ignore_js_op>
Dokku
Pass Cloud Docker Introduction