Docker 在 Mac 上撰写 - 图片位置
Docker Compose on Mac - Image Location
我在 Mac 上使用 docker-compose 进行本地开发。我有多个正在使用 docker compose 构建的图像。我的 docker 和 docker-compose 设置非常标准。现在我想与某人共享我在本地构建的图像文件。这些本地文件存储在哪里?
稍微搜索了一下,得到了如下答案:
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
但是我怎样才能从中提取一张图片并分享呢?我尝试了 运行 随附的 tty
,但无济于事。
Docker 版本:18.03 Docker 用于 Mac
Docker 撰写版本:2
如果您有 docker-hub 帐户(免费),那么您可以使用 docker push 命令将 docker 图像保存到注册表并使用 docker pull 到在其他机器上拉。
另一种解决方案是使用 保存 + 导入 命令。
为此,您可以使用 docker save
和 docker import
命令。
docker@default:~$ docker save --help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
docker@default:~$
之后你的文件系统上有 TAR 文件(检查 -o 值)然后将文件传输到另一台机器并执行 docker import
docker@default:~$ docker import --help
Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Import the contents from a tarball to create a filesystem image
Options:
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Set commit message for imported image
docker@default:~$
显然,docker-compose
的解决方案是使用 docker save
命令。我们不需要像 @fly2matrix 提到的那样知道图像的位置。我们可以使用 docker save
命令将图像保存在 TAR 文件中。
docker save --output image-name.tar image-name:tag
然后其他用户可以通过以下方式共享和加载此图像:
docker load --input image-name.tar
我在 Mac 上使用 docker-compose 进行本地开发。我有多个正在使用 docker compose 构建的图像。我的 docker 和 docker-compose 设置非常标准。现在我想与某人共享我在本地构建的图像文件。这些本地文件存储在哪里?
稍微搜索了一下,得到了如下答案:
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
但是我怎样才能从中提取一张图片并分享呢?我尝试了 运行 随附的 tty
,但无济于事。
Docker 版本:18.03 Docker 用于 Mac
Docker 撰写版本:2
如果您有 docker-hub 帐户(免费),那么您可以使用 docker push 命令将 docker 图像保存到注册表并使用 docker pull 到在其他机器上拉。
另一种解决方案是使用 保存 + 导入 命令。
为此,您可以使用 docker save
和 docker import
命令。
docker@default:~$ docker save --help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
docker@default:~$
之后你的文件系统上有 TAR 文件(检查 -o 值)然后将文件传输到另一台机器并执行 docker import
docker@default:~$ docker import --help
Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Import the contents from a tarball to create a filesystem image
Options:
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Set commit message for imported image
docker@default:~$
显然,docker-compose
的解决方案是使用 docker save
命令。我们不需要像 @fly2matrix 提到的那样知道图像的位置。我们可以使用 docker save
命令将图像保存在 TAR 文件中。
docker save --output image-name.tar image-name:tag
然后其他用户可以通过以下方式共享和加载此图像:
docker load --input image-name.tar