【Docker】从 Docker 镜像中下载内容到本地

使用 docker run 命令启动镜像并进入容器。

docker run -it --name my-container my-image:tag /bin/bash

其中 my-container 为你给容器取的名字。

在容器中进行所需的操作,例如下载文件到容器中。

使用 docker cp 命令将容器中的文件复制到本地。

docker cp my-container:/path/to/file /local/path

其中 /path/to/file 为容器中要复制的文件路径,/local/path 为本地路径。

从本地上传内容到 Docker 容器:
使用 docker cp 命令将本地文件复制到容器中。

docker cp /local/path my-container:/path/to/file

其中 /local/path 为本地文件路径,my-container 为容器名字,/path/to/file 为容器中要复制的目标路径。

在容器中进行所需的操作,例如解压缩文件或者安装软件等。

使用 docker commit 命令将修改后的容器保存为新的镜像。

docker commit my-container my-image:tag

其中 my-image:tag 为新的镜像名称和版本号。

猜你喜欢

转载自blog.csdn.net/weixin_47665864/article/details/130090617