Changing disk space of container partition

I used the command mentioned on the official docker page.

  • Swarm Networking and Spring Cloud Apps
  • Editing Docker container FS using Atom/Sublime-Text?
  • Bundle optimization for ruby on Docker
  • How do I find the network ip using docker and travis?
  • Oracle 11g docker SELECT very slow
  • Deleting files inside docker container not freeing up space on host system
  • official command:

    docker run -i -t -p 8888:8888 continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser"

    I mounted tmp folder within the container and used it as home directory because for some reason the root partition had only 10 GB disk allocated.

    docker run -i -t -p 8888:8888 -v /tmp/:/tmp/ continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && cd /tmp/ && /opt/conda/bin/jupyter notebook --ip='*' --port=8888 --no-browser --allow-root"

    I will like to know if there is any better way of doing this. The size of root partition should be the same as host machine hard disk capacity.


    I am using Dockerfile as suggested by shizhz. But here is the correct command if in case I need it:

    docker run -i -t -p 8888:8888 -v /tmp:/tmp continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && cd /tmp/ && /opt/conda/bin/jupyter notebook --notebook-dir=/tmp --ip='*' --port=8888 --no-browser --allow-root"

  • PHPUnit Selenium tests fail on Docker localhost and pass using public IP
  • Unable to execute shell script with parameter from Dockerfile
  • Setup private docker registry with anonymous pull access
  • Mounting nfs shares inside docker container
  • Why log settings don't work without setting --log-driver option while service creation?
  • Referencing files inside build (Docker)
  • 2 Solutions collect form web for “Changing disk space of container partition”

    This is not about your disk partition but I think you’re doing too much things in startup shell, I’d like to suggest you to define your own Dockerfile and build your own image. I test with the following Dockerfile:

    FROM continuumio/miniconda3
    RUN /opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks
    VOLUME /opt/notebooks
    EXPOSE 8888
    WORKDIR /opt/notebooks
    CMD ["/opt/conda/bin/jupyter", "notebook", "--notebook-dir=/opt/notebooks", "--ip='*'", "--port=8888", "--no-browser", "--allow-root"]

    Then build your own image:

    docker build -t jupyter .

    After than you can easily start your service like:

    docker run -d -v `pwd`/notebooks:/opt/notebooks -p 8888:8888 jupyter

    Of course you can mount any directory on your host to VOLUME /opt/notebooks inside container.

    Docker by default allocates 10G of the data irrespective of the size of your host computer.

    There are some recent developments in this area and docker 3.18.0 has the best way of handling the things. Details of the same are available in docker documentation.

    As per the documentation, you would have to use the following sequence of commands to increase the base size of the containers/ images.

    • Please note the above command is an irreversable operation. Once you have set the size to 50G, you can’t ever get it reduced.
    • Also, this partition is currently possible only on ext4 partitions. Hence your host machine should have ext4 partition where docker is running and creating containers/ images from.

      $ sudo dockerd --storage-opt dm.basesize=50G
    • To let the changes take effect, you have to run the following commands:

      $ sudo service docker stop
      $ sudo rm -rf /var/lib/docker
      $ sudo service docker start

    Also, please note that this will effect all the future images that you pull / build and future containers you create. Existing containers are not affected by this command. Hence, you might have to re-create your images and re-create your containers.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.