Changing disk space of container partition

I used the command mentioned on the official docker page.

https://hub.docker.com/r/continuumio/miniconda3/

  • How to configure Docker port mapping to use Nginx as an upstream proxy?
  • How can I connect to a docker container using its name instead of its IP address?
  • Issue in building docker image using habitus
  • Switch from Heroku to Docker on Digitalocean [Continuous Integration] [closed]
  • Jenkins with Docker plugin java.lang.NullPointerException: uri was not specified
  • Can't require ruby gsl on Alpine Linux
  • 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.


    Update:

    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"
    

  • Updating jar in docker image
  • Docker: In Dockerfile, copy files temporarily, but not for final image
  • Can I export a container with data and everything to spawn a complete copy on another computer?
  • Docker build npm error logs
  • Confused about Docker -t option to Allocate a pseudo-TTY
  • How to manage deployment?
  • 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.