How to import/save/load/delete images locally in Docker

How to import/save/load/delete images locally in Docker

1. Docker imports local images

Sometimes we copy an image locally or on another friend's computer. With this image, we can import the local image using the docker import command.

For example, here we download an alibaba-rocketmq-3.2.6.tar.gz image file and import it using the following command:

[root@rocketmq-nameserver4 dev]# cat alibaba-rocketmq-3.2.6.tar.gz | docker import - rocketmq:3.2.6 (the image name is defined by yourself)
[root@rocketmq-nameserver4 dev]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rocketmq 3.2.6 53925d1cf9f0 23 seconds ago 14MB
my/python v1 36b6e288656c 2 days ago 281MB
my/centos_width_python v1.0.1 36b6e288656c 2 days ago 281MB
my/sinatra v2 8ba1d6a3ce4e 2 days ago 453MB
hello-world latest 725dcfab7d63 4 months ago 1.84kB

You can see that after the import is complete, Docker generates an image ID for us. You can also use Docker images to see the image we just imported from the local computer.

Note that the image file must be a tar.gz file.

[root@rocketmq-nameserver4 dev]# docker run -it rocketmq:3.2.6 /bin/bash ##Start importing the local image, the following exception will be reported
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory".

Solution: There is no solution for now. If anyone knows, please leave a comment below. Thanks in advance.

2. Save the image

After our image is completed, we need to save it for backup. How to do it? Use the docker save command to save the image locally.

[root@rocketmq-nameserver4 dev]# docker save -o rocketmq.tar rocketmq ##-o: specifies the name of the saved image; rocketmq.tar: the name of the image saved locally; rocketmq: the image name, view it through "docker images" [root@rocketmq-nameserver4 dev]# ll 


rocketmq.tar is the image just saved

3. Load the image

Now that we have a local image file, we can use docker load to import the locally saved image into docker again when needed.
docker load --input rocketmq.tar or docker load < rocketmq.tar

4. Delete the image

Some images are outdated and we need to remove them. Use the following command: docker rmi -f image_id ##-f: means forced deletion of the image; image_id: image id

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to export and import images between docker
  • How to save Docker images as files and import images from files
  • How to create, save, and load Docker images
  • Docker tutorial: saving and loading images, removing and implementing images
  • How to solve the problem that Docker Image cannot be deleted
  • Detailed explanation of docker forced batch deletion of none image mirrors
  • How to delete the none image in docker
  • Docker Tips: Deleting Docker Containers and Images

<<:  MySQL uses variables to implement various sorting

>>:  Detailed explanation of for loop and double for loop in JavaScript

Recommend

Interpreting MySQL client and server protocols

Table of contents MySQL Client/Server Protocol If...

Mysql 5.6.37 winx64 installation dual version mysql notes

If MySQL version 5.0 already exists on the machin...

A brief discussion on several specifications of JS front-end modularization

Table of contents Preface The value of front-end ...

Tutorial on installing Pycharm and Ipython on Ubuntu 16.04/18.04

Under Ubuntu 18.04 1. sudo apt install python ins...

Solve the problem of not finding NULL from set operation to mysql not like

An interesting discovery: There is a table with a...

The whole process of Vue page first load optimization

Table of contents Preface 1. Image Optimization 2...

Solution to forgetting mysql password under linux

The problem is as follows: I entered the command ...

Detailed explanation of Vue's custom event content distribution

1. This is a bit complicated to understand, I hop...

How to use vue.js to implement drag and drop function

Preface Adding drag and drop functionality is a g...

Webpack file packaging error exception

Before webpack packaging, we must ensure that the...

How to install MySQL via SSH on a CentOS VPS

Type yum install mysql-server Press Y to continue...

How to deploy LNMP & phpMyAdmin in docker

Environmental preparation: Deploy lnmp on a host ...

Three implementation methods of Mysql copy table and grant analysis

How to quickly copy a table First, create a table...

Detailed explanation of soft links and hard links in Linux

Table of contents 1. Basic storage of files and d...

How to export mysql query results to csv

To export MySQL query results to csv , you usuall...