Example of exporting and importing Docker containers

Example of exporting and importing Docker containers

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

Exporting Docker containers

1. First use the command to view the created Docker container

 docker ps -a 

insert image description here

At this time, you can see container id , which is the container ID. We can export the corresponding container based on the container ID.

2. Export a container

Exporting a container is very simple. Use the docker export command. The syntax is: 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 to download:

insert image description here

Wait for the container file to download

insert image description here

Importing Docker containers

Import a container – docker import command

Now that 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

As mentioned above, the directory exported by the container is under tmp, so let's go directly to the tmp directory

 cd /tmp 

insert image description here

2. Import container

 docker import halo.tar halo:latest

OPTIONS description:

-halo.tar : select the container file name to import
-halo:latest : Specify container name and version

The import and export process is similar, so I won’t show you the pictures here.

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

 rm -rf /tmp/halo.tar

This is the end of this article about exporting and importing Docker containers. For more information about exporting and importing Docker containers, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker image import and export code examples
  • Implementation of importing and exporting docker images
  • Docker image import, export, backup and migration operations
  • Docker image export, import and copy example analysis
  • How to import and export Docker images
  • Tutorial on importing and exporting Docker containers
  • How to export and import images between docker
  • Docker realizes export, import and data migration
  • Docker practice: importing and exporting containers
  • Docker image and container import and export operations practice

<<:  HTML+Sass implements HambergurMenu (hamburger menu)

>>:  5 basic skills of topic page design (Alibaba UED Shanmu)

Recommend

How to make a tar file of wsl through Docker

I've been playing with the remote development...

Vue commonly used high-order functions and comprehensive examples

1. Commonly used high-order functions of arrays S...

Vue implements zoom in, zoom out and drag function

This article example shares the specific code of ...

Detailed explanation of js's event loop event queue in the browser

Table of contents Preface Understanding a stack a...

Detailed explanation of memory management of MySQL InnoDB storage engine

Table of contents Storage Engine Memory Managemen...

How to Check Memory Usage in Linux

When troubleshooting system problems, application...

Quickly solve the problem that the mysql57 service suddenly disappeared

one, G:\MySQL\MySQL Server 5.7\bin> mysqld --i...

Nginx proxy axios request and precautions

Preface I recently wrote a small demo. Because I ...

How to optimize MySQL query speed

In the previous chapters, we introduced how to ch...

How to modify the mysql table partitioning program

How to modify the mysql table partitioning progra...

Analysis of slow insert cases caused by large transactions in MySQL

【question】 The INSERT statement is one of the mos...

Some basic instructions of docker

Table of contents Some basic instructions 1. Chec...

MySQL startup error InnoDB: Unable to lock/ibdata1 error

An error message appears when MySQL is started in...