Docker container packaging and deployment

overview

This article describes how to package and deploy applications using Docker containers. It first introduces the concept and basic use of Docker containers, and then introduces in detail how to use Dockerfile to build Docker images, and use the docker commit command to package them into images. Finally, we covered how to start containers using the docker run command. Through the explanation in this article, readers can understand the basic process and method of Docker container packaging and deployment, and be able to skillfully use Docker commands for container packaging and deployment.

Overview of Docker containers

A Docker container is a lightweight, portable virtualization technology that packages an application and all its dependencies into an isolated runtime environment. Docker containers use Docker images as a foundation to quickly create and deploy applications. The Docker container can be started through the docker run command and mount the local directory to implement the deployment of the application.

Make a Docker container as a Docker image

docker commit 容器ID imagexxx:v1

Make the Docker image into a tar package

docker save -o 名称.tar 新创建的镜像名称:版本号
或
docker save 新创建的镜像名称:版本号>名称.tar

Move the prepared tar package to the environment that needs to be deployed.

Generate a Docker image from the tar package

docker load < xxx.tar

Use the docker run command to start the container and mount the local directory

docker run -v /path/to/local/directory:/path/to/container/directory <image-name>  

where is the name of the Docker image to use, /path/to/local/directory is the local directory to mount, and /path/to/container/directory is the directory to mount to the container.

Summarize

Work essay, I hope it can help everyone!
If there are deficiencies, please advise!

Guess you like

Origin blog.csdn.net/black_lightning/article/details/131669410