惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
SecWiki News
SecWiki News
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
腾讯CDC
Scott Helme
Scott Helme
I
InfoQ
Cyberwarzone
Cyberwarzone
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Latest
Security Latest
The Register - Security
The Register - Security
Project Zero
Project Zero
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
C
Cisco Blogs
L
LINUX DO - 热门话题
P
Privacy International News Feed
IT之家
IT之家
U
Unit 42
P
Privacy & Cybersecurity Law Blog
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Palo Alto Networks Blog
F
Full Disclosure
宝玉的分享
宝玉的分享
Simon Willison's Weblog
Simon Willison's Weblog
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
PCI Perspectives
PCI Perspectives
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog

Docker 从入门到实践

修订记录 如何贡献 Docker — 从入门到实践 高级网络配置 容器访问控制 自定义网桥 编辑网络配置文件 配置 docker0 网桥 工具和示例 映射容器端口到宿主主机的实现 示例:创建一个点到点连接 快速配置指南 附录 Dockerfile 最佳实践 Docker 命令查询 客户端命令(docker) 服务端命令(dockerd) 如何调试 Docker 常见问题总结 热门镜像介绍 Node.js 资源链接 归档项目 基本概念 Docker 容器 Docker 镜像 Docker Buildx 使用 BuildKit 构建镜像 使用 Buildx 构建镜像 使用 buildx 构建多种系统架构支持的 Docker 镜像 CI/CD GitHub Actions Drone Demo Drone 部署 Drone Alpine Busybox CentOS/Fedora Debian/Ubuntu 容器与云计算 亚马逊云 腾讯云 Docker Compose 项目 Compose 命令说明 Compose 模板文件 使用 Django 安装与卸载 Compose 简介 使用 compose 搭建 LNMP 环境 使用 Rails 使用 使用 WordPress 操作 Docker 容器 进入容器 后台运行 删除容器 启动容器 终止容器 Fedora CoreOS 安装 Fedora CoreOS Fedora CoreOS 介绍 Docker 数据管理 挂载主机目录 数据卷 etcd 集群 使用 etcdctl 使用 etcdctl v2 什么是 etcd 在 IDE 中使用 Docker VS Code 中使用 Docker 使用 Dockerfile 定制镜像 使用 Docker 镜像 利用 commit 理解镜像构成 Dockerfile 指令详解 ADD 更高级的复制文件 ARG 构建参数 CMD 容器启动命令 COPY 复制文件 ENTRYPOINT 入口点 EXPOSE 声明端口 CentOS minio MongoDB MySQL Nginx PHP Redis Ubuntu WordPress Docker Registry 操作系统 本章小结 阿里云 简介 本章小结 etcd 安装 Docker — 从入门到实践
导出和导入容器
2022-05-13 · via Docker 从入门到实践

# 导出和导入容器

# 导出容器

如果要导出本地某个容器,可以使用 docker export 命令。

$ docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                    PORTS               NAMES
7691a814370e        ubuntu:18.04        "/bin/bash"         36 hours ago        Exited (0) 21 hours ago                       test
$ docker export 7691a814370e > ubuntu.tar

1
2
3
4

这样将导出容器快照到本地文件。

# 导入容器快照

可以使用 docker import 从容器快照文件中再导入为镜像,例如

$ cat ubuntu.tar | docker import - test/ubuntu:v1.0
$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
test/ubuntu         v1.0                9d37a6082e97        About a minute ago   171.3 MB

1
2
3
4

此外,也可以通过指定 URL 或者某个目录来导入,例如

$ docker import http://example.com/exampleimage.tgz example/imagerepo

1

注:用户既可以使用 docker load 来导入镜像存储文件到本地镜像库,也可以使用 docker import 来导入一个容器快照到本地镜像库。这两者的区别在于容器快照文件将丢弃所有的历史记录和元数据信息(即仅保存容器当时的快照状态),而镜像存储文件将保存完整记录,体积也要大。此外,从容器快照文件导入时可以重新指定标签等元数据信息。