Docker Introduction
Categories:
- Docker Introduction
Docker Introduction
- Docker is an application container engine that can package an application and its dependencies into a portable container, which can then be published to any popular Linux or Windows machine, and can also achieve virtualization.
- Why does Docker exist? Because development and operations teams often encounter a class of problems: an application runs without any issues in the developer’s environment but is full of bugs in the actual production environment.
- The execution of a program involves different layers, from the hardware architecture to the operating system, and then to the application itself. However, developers often focus only on application development, ignoring issues at other layers.
- Docker was created to solve this problem. It packages the application and its dependencies into a container, so you don’t have to worry about environmental issues.
- It synchronizes the development and production environments, allowing developers to locally develop, test, and deploy applications without worrying about environmental inconsistencies. This significantly improves the efficiency of development and operations, at the cost of a slight waste of resources.
I strongly recommend that all developers learn to use containers for development and deployment. It provides a stable runtime environment for your application at a relatively low cost, thereby improving the efficiency of both development and operations.
Here is a workflow for using Docker, described in simple terms:
- Create a development environment from scratch, including the operating system, application, dependency packages, configuration files, etc.
- The environment can run anywhere and be created anywhere.
- The results of compiling the source code in the environment are stable and predictable, with completely consistent behavior.
- The execution of programs within the environment is unambiguous.
- It’s best to use a declarative method (like docker-compose) to create the environment, further reducing hidden discrepancies and making everything about the environment explicit in the declaration.
- Create a commit and an image. This is like taking a snapshot, saving the current environment for future use.
- Share the image with other developers and operations personnel, so everyone can work synchronously based on the same context.
- As business needs evolve, modify the image, create a new commit, rebuild the image, and redistribute it.