What is Docker used for? 【Quick Start】

Since last year, Docker can not only run under Linux, but also support mainstream systems such as windows and osX.
The following examples are often used by myself, of course you can share with me if you have better cases.

try new software

For developers, all kinds of new technologies that are born every day need to be tried, but developers are unlikely to set up an environment for them and test them one by one. Time is precious, and thanks to Docker, it's possible to set up an environment in one or a few commands. Docker has a fool-proof way to obtain software, the Docker background will automatically obtain the environment image and run the environment.

It's not just new technology environments that get Docker. If you want to quickly run a MySQL database, or a Redis message queue on your laptop, it's very easy to do with Docker. E.g

Docker can run a MySQL database with just one command:

docker run -d -p 3306:3306 tutum/mysql。

Translator's Note: Although the MySQL database can be installed very quickly using the command, but when using the latest technology or very complex technology, using Docker can be a very good choice, such as:

event general user Docker users
Install Gitlab one day a command

give a demo

Now I often need to give a demo or two to clients and others on the weekends with the results I developed. The process of setting up a demo environment is very cumbersome. Now I find Docker to be the most logical way for me to demonstrate these tools.

For customers, I can directly provide Docker images to them without having to do any environment configuration work, and the effect will be exactly as seen in their demos, without worrying that their environment configuration will cause Our product does not work.

Avoid " it works on my machine " (but not on someone else's machine)

This is the case for both the enterprise deployment of Docker described in the previous article and the personal Docker use case for this article. Because the environment configuration is different, many people will also encounter this situation during development, and even the developed software cannot be run on the tester's machine. But that's not the point. The point is, if we had a reliable, distributable standard development environment , our development would be less painful than it is now. Docker can solve this problem. Docker images will not fail to run due to changes in the environment, nor will they run differently on different computers. The Docker image containing the application can be submitted to the tester, so that "it can be run on my machine" will no longer happen, which greatly reduces the time cost of developers and testers to check the machine environment settings with each other .

Another place where Docker can come into play is in training classes. In addition to the isolation of Docker containers, the advantage of Docker is in the construction of the environment. Everyone who is new to the training class will spend a lot of time on the environment, but if it is applied to Docker here, then we only need to distribute the standard operating environment image, and then we can start the class. Using Docker is as easy as using a virtual machine, but Docker is more convenient and lightweight. At the same time, we can also tell the trainees: "At the same time of training, we will also learn the most popular technology - Docker". Why not do this kind of win-win outcome.

better use of resources

The granularity of virtual machines is "virtualized machines", while the granularity of Docker is "restricted applications". In comparison, Docker occupies less memory and is more lightweight.

For me this is an advantage of Docker: since I often run multiple Docker applications on my computer, using Docker is simpler, more convenient, more granular, and keeps track of container state than using a virtual machine.

Customize for Microservices

If you've been following tech news, you've probably heard of the concept of "Microservices". Docker works well with microservices. Conceptually, a microservice is a subset of the functionality that provides a complete set of applications, and Docker acts as a container for the microservice throughout development, testing, and deployment. Even production environments can deploy microservices in Docker.

Porting between cloud service providers

Most cloud hosting providers already fully support Docker. For developers, this means that you can easily switch cloud service providers, and of course, you can easily move your local development environment to the cloud host, without the need to configure the running environment locally and install it on the cloud host. Also configure the runtime environment once. Fully deploying Docker (Docker here and Docker there) as a standard operating environment can greatly reduce the workload and bugs when the application is launched.

API

API is the glue between applications. A qualified developer must have used the REST API provided by others, or developed the REST API by himself. It should be pointed out that before development, both the client and the API provider need to define a set of public API interfaces and write them into documents before coding. If the server and the client are jointly developed, the server usually implements the API interface that can return a fixed string first, and then slowly implements the API function in the future development.

Although some people will think that Docker is abused here, it is completely possible to use the file sample.json to implement virtual APIs, but the following example can better solve the API problem when the front-end and back-end are separated and developed.

To better explain what I mean, let me give you an example: JSON Server, a REST API for serving JSON data. Anyone who has used this container will know that since Docker JSON Server is so useful, there is no reason why we should not use Docker.

Translator's Note:

Run the JSON Server of the example, and use the JSON file provided in the example to create a server-side API application with just one command. 
Use curl  http://127.0.0.1:80/posts  to get the posts segment in the sample file, so that when the API is not developed on the back-end, the front-end can also be developed collaboratively.

technological innovation

This shouldn't count as a use case, but I'll write about it anyway. Docker is evolving rapidly and the tools are constantly being updated, and no one could have foreseen what the future of Docker would look like. The more you use Docker in complex systems, the more likely you are to discover technical gaps and future directions for technology development. It's still in the development phase of Docker, and any tool you create with Docker has the potential to become a hot spot in the community. This is an opportunity for Docker and an opportunity to be yourself.

other

There are two more tricks to share with you. In the process of learning Docker, because of the help of these two, I am proud to constantly improve myself.

One: Docker Hub Registry. This is the official image repository of Docker. In addition to hosting the official images of Docker, like Github, you can upload your own images on it, and you can also search for other useful images on it, which greatly saves your time. For example, the Oracle-XE-11g image, everything is ready-made, there is no need to download Oracle XE 11g installation. This saves you and your team a lot of time and cost.

If you are not sure, you can go to Docker Hub and search for images that you can use. In most cases the images you need are already built on Docker Hub.

Two: Refer to the news of IaaS providers. Although we can't fully understand their company's dynamics as in their conference room, we can still learn about the latest development direction and technology trends of Docker from the news. It is certain that containerization technology is the hot spot in the future. We can not only run Docker on the machine, not only on the host of one cloud service provider, but all cloud service providers will support Docker in the future.

The future of Docker is clear, and adopting Docker will only make development easier.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324371371&siteId=291194637