如何将Docker映像提取到本地系统 [英] How to extract the Docker image into local system

查看:283
本文介绍了如何将Docker映像提取到本地系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Docker映像(从Ubuntu服务器中)提取到本地系统(Linux计算机)中。

I want to extract the Docker image (from Ubuntu server) into my local system (Linux machine).

我运行以下命令

docker exec -it containername_or_ID /bin/bash

我可以使用此命令查看图像,但无法将此图像放入本地系统。

I am able to view image by using this command, but I am unable to get this image into my local system.

推荐答案

但这取决于您的实际要求。您在谈论提取图像,但是您是指现有的容器。尽管jbrownwrld的答案就在您的上下文中,但如果您要提取图像,则可以使用docker save。
使用以下方式识别映像:

It depends though on what you're actually asking for. You are talking about extracting the image, but you're referring to an existing container. While jbrownwrld's answer is right in your context, if you want to extract an image, you can use docker save for that. Identify the image using:

docker image ls
mariadb                 10.3-bionic         92744546933d        4 days ago          343MB

然后输出tar文件(默认格式):

Then output the tar file (default format):

docker save mariadb:10.3-bionic --output mariadb.tar
mkdir mariadb && mv mariadb.tar mariadb && cd mariadb && tar xvf mariadb.tar

正在提取大量文件和文件夹,因此最好使用另一个目录。这些文件夹通常对应于图像层。

There are lots of files and folders being extracted, so you had better use another directory. The folders generally correspond to the image layers.

这篇关于如何将Docker映像提取到本地系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆