Skip to content

解决 Mac Docker.qcow2 文件过大的问题 #3

Open

Description

@ninehills

背景:Docker on Mac 长时间运行后,Docker.qcow2就会变得很大,需要压缩

参考:docker/for-mac#371

Author: yankcrime
NB: You'll need to install qemu via Homebrew as this process requires qemu-img to recompress the qcow2 disk image.

$ cd ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux
$ mv Docker.qcow2 Docker.qcow2.original
$ du -hs Docker.qcow2.original
12G     Docker.qcow2.original
$ qemu-img convert -O qcow2 Docker.qcow2.original Docker.qcow2
$ rm Docker.qcow2.original
$ du -hs Docker.qcow2
772M    Docker.qcow2

除此之外,还有一个根本解决问题的方法,就是不要在虚拟机内保存任何数据,全部使用Volume,这样当文件过大时,删除文件,重启Docker后,重新创建容器即可。

Activity

  1. ninehills commented on Jul 13, 2017

    @ninehills
    OwnerAuthor

    回复也记录下常用的一些容器的启动,用于备忘:

    # jupyter with spark
    docker run -p 8888:8888 -d -v /Users/baidu/WorkSpace/Jupyter:/home/jovyan/work --name all-spark-notebook jupyter/all-spark-notebook
    # jupyter with go
    docker run -p 8887:8888 -d -v /Users/baidu/WorkSpace/Jupyter:/go/workspace --name go-notebook dwhitena/gophernotes jupyter notebook --no-browser --ip=0.0.0.0
    
  2. added a commit that references this issue on Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions