How to assign more memory to docker container

As the title reads, I’m trying to assign more memory to my container. I’m using an image from docker hub called “aallam/tomcat-mysql” in case that’s relevant.

When I start it normally without any special flags, there’s a memory limit of 2GB (even though I read that memory is unbounded if not set)

  • Adding nodes to shipyard
  • When we execute docker run ubuntu:14.04 ps ax, where does ps ax command runs?
  • Ping Docker Container from another machine in the network
  • How to enable user defined functions in docker instance of cassandra?
  • Getting an error while trying to use a command under the lifecycle tag on kubernetes
  • How-to install and run keen/dashboards
  • Here are my docker stats

    CONTAINER           CPU %               MEM USAGE / LIMIT       MEM %               NET I/O             BLOCK I/O           PIDS
    ba57d6c9e9d2        0.22%               145.6 MiB / 1.952 GiB   7.29%               508 B / 508 B       0 B / 6.91 MB       68
    

    I tried setting memory explicitly like so but with same results

    docker run -d --memory=10g --memory-swap=-1 -e MYSQL_PASSWORD=password -p 3307:3306 -p 8081:8080 aallam/tomcat-mysql
    

    I’ve read that perhaps the VM is what’s restricting it. But then why does docker stats show that container size limit is 2GB?

  • Using a dedicated proxy container in front of Rails app container
  • How can I make JHipster applications REST services run on different docker containers?
  • Ansible, running role multiple times with different parameter sets
  • Dockerfile with entrypoint for executing bash script
  • Access web server over https in a Docker container
  • Grafana + InfluxDB configuration
  • One Solution collect form web for “How to assign more memory to docker container”

    That 2GB limit you see is the total memory of the VM in which docker runs.

    If you are using docker-for-windows or docker-for-mac you can easily increase it from the Whale icon in the task bar (go to Settings, etc)

    If you are using VirtualBox behind, open VirtualBox, Select and configure the docker-machine assigned memory.

    See this for Mac:

    https://docs.docker.com/docker-for-mac/#memory

    MEMORY
    By default, Docker for Mac is set to use 2 GB runtime memory, allocated from the total available memory on your Mac. You can increase the RAM on the app to get faster performance by setting this number higher (for example to 3) or lower (to 1) if you want Docker for Mac to use less memory.

    For Windows:

    https://docs.docker.com/docker-for-windows/#advanced

    Memory – Change the amount of memory the Docker for Windows Linux VM uses

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