Export and import Docker containers

Export and import Docker containers

This article mainly explains the import and export of Docker containers, which can be used as backups for container snapshots.


Today's picture~
insert image description here

Docker container export

1. First use the command to view the Docker container that has been created

docker ps -a

insert image description here

At this time, you can see that container idit is the container ID. We only need to export the corresponding container according to the container ID.

2. Export a container

Exporting a container is very simple, using the docker exportcommand, syntax:docker export $container_id > 容器快照名

insert image description here

3. View the exported container

ls

insert image description here

4. Download the container

View the current path

pwd

insert image description here

Knowing that the container path is under tmp, we can directly use the FTP remote tool to connect to the host for download:

insert image description here

Wait for the container file to download

insert image description here

Import of Docker container

Import a container – docker import command

Once we have a container snapshot, we can import it whenever we want. Import snapshots using the docker import command.

1. First go to the directory where the container file is located

We mentioned above that the directory exported by the container is under tmp, then we go directly to the tmp directory,

cd /tmp

insert image description here

2. Import the container

docker import halo.tar halo:latest

OPTIONS Description:

-halo.tar : select the container filename to import
-halo:latest : specify the container name and version

The process of importing and exporting is similar, and there is no picture demonstration here.

3. You can delete the container file after you are done

rm -rf /tmp/halo.tar

Guess you like

Origin blog.csdn.net/qq_31762741/article/details/122243209