rofrano / vagrant-docker-provider

Build a docker image that can be used in vagrant as a development environment
Apache License 2.0
101 stars 51 forks source link

Container take heavy space #3

Closed phareal closed 3 years ago

phareal commented 3 years ago

hello firstly thank you for your work . it help me a lot . But i just noticed that running this image take more than 30% of my hard disk i don't know if it's coming from my vagrantfile or not

https://pastebin.com/Pwr5Kq1r

that is the link to my vagrantfile
Thank you for your help

Os information

Mac m1 Ram : 8go Os Big sur

rofrano commented 3 years ago

Hi @phareal, When you say the image is taking 30% of your hard drive space, do you mean the hard drive space allocated to Docker? Because Docker Desktop for Mac allocates 60GB for the VM that it runs in the background. It will never take up more than 60GB of physical hard drive space on your Mac unless you increase this limit.

As for your Vagrantfile, I would not install Docker yourself. I would let Vagrant install Docker for you. All you need to do is add:

config.vm.provision :docker

That's it! The provision blocks of your Vagrantfile could be reduced to these two:

  # Install package for your VM
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update -y
    apt-get install -y git \
        apt-transport-https \
        build-essential \
        curl \
        gnupg-agent \
        software-properties-common \
        python3-pip

    pip3 install docker-compose 

    echo "cd /opt/atlas-blue" >> /home/vagrant/.bashrc
  SHELL

  config.vm.provision "docker"

That's all you need and Vagrant takes care of the rest. It will install Docker and place the vagrant user in the docker group so that you can use it without sudo. You probably don't need gnupg-agent and other packages you installed just to install Docker. Notice I use pip3 to install docker-compose so that it works on arm64. The docker-compose build does not support arm64 but the pip package does.

Here is an example Vagrantfile from a repo that I use in my DevOps class at NYU that installs Docker and pulls a PostgreSQL image and runs it. Let me know if you have any questions and if that helped reduce the space Docker takes up.

phareal commented 3 years ago

OK let me try cause actually i have allocated 100 gb for docker on my computer and just for installing the package like php ,node ,traefik 80% of the allowed space was used . When i was using just docker i just allocated 50gb and it's run fine and running the same scripts just use 2gb of the allocated space

Thank you for your help

phareal commented 3 years ago

Thank it work better ,i'll close the issue

rofrano commented 3 years ago

Glad that worked!