Take Nginx as an example:
1. First deploy the Nginx service on the 183 server:
① Pull the mirror
docker pull nginx:latest
②Run the container
docker run --name nginx-test -p 12308:80 -d nginx
Parameter description:
--name nginx-test: container name.
-p 12308:80: port mapping, mapping the local port 12308 to port 80 inside the container.
-d nginx: Set the container to always run in the background.
③View the container process
docker ps -a
Visit 192.168.1.183:12308, the visit is successful:
2. Save the container as an image
docker commit container name mirror name
docker commit nginx-test nginxtest
This can be seen as an additional Nginx image, which is the one we just generated.
3. Pack the image into a tar file
docker save -o xxx.tar image name
docker save -o nginxTest.tar nginxtest
或
docker save nginxtest > nginxTest.tar
Note: If you need to merge multiple images into a tar package:
docker save [images] [images] > [name.tar]
4. Download the tar file and upload it to other servers (185)
5. Mirror recovery
Execute the following command to restore:
docker load < xxx.tar
或
docker load -i xxx.tar
At this time, the nginxtest image appears in the docker of the 185 server.Execute the
following command to start the container:
docker run --name nginx-test -p 12309:80 -d nginxtest
Visit 192.168.1.185:12309, the visit is successful: