2016-01-24 57 views
1

以下是我擁有的泊塢窗容器和圖像的詳細信息。我們如何設置碼頭集裝箱的RAM和磁盤空間?

Animeshs-MacBook-Pro:docker_tests animesh$ docker-machine ls 
NAME   ACTIVE URL   STATE  URL       SWARM DOCKER ERRORS 
celery-test *  virtualbox Running tcp://192.168.99.100:2376   v1.9.1  
hello-world -  virtualbox Stopped          Unknown 

Animeshs-MacBook-Pro:docker_tests animesh$ docker ps -a 
CONTAINER ID  IMAGE    COMMAND    CREATED    STATUS      PORTS    NAMES 
33f0eca77b4c  celery-image1  "/bin/bash"   2 hours ago   Exited (0) 25 minutes ago      current_image 
a4607f34b309  ubuntu:latest  "/bin/bash"   4 hours ago   Exited (0) 3 hours ago       celery_app 

Animeshs-MacBook-Pro:docker_tests animesh$ docker-machine ssh celery-test 
Boot2Docker version 1.9.1, build master : cef800b - Fri Nov 20 19:33:59 UTC 2015 
Docker version 1.9.1, build a34a1d5 

[email protected]:~$ df -h 
Filesystem    Size  Used Available Use% Mounted on 
tmpfs     896.6M 889.6M  7.0M 99%/
tmpfs     498.1M   0 498.1M 0% /dev/shm 
cgroup     498.1M   0 498.1M 0% /sys/fs/cgroup 
none     464.8G  44.0G 420.8G 9% /Users 
tmpfs     896.6M 889.6M  7.0M 99% /mnt/sda1/var/lib/docker/aufs 

[email protected]:~$ exit 

Animeshs-MacBook-Pro:docker_tests animesh$ docker start current_image 
current_image 

Animeshs-MacBook-Pro:docker_tests animesh$ docker ps -a 
CONTAINER ID  IMAGE    COMMAND    CREATED    STATUS     PORTS    NAMES 
33f0eca77b4c  celery-image1  "/bin/bash"   2 hours ago   Up 3 seconds         current_image 
a4607f34b309  ubuntu:latest  "/bin/bash"   4 hours ago   Exited (0) 3 hours ago      celery_app 

Animeshs-MacBook-Pro:docker_tests animesh$ docker attach current_image 
[email protected]:/# df -h 
Filesystem  Size Used Avail Use% Mounted on 
none   897M 890M 7.0M 100%/
tmpfs   499M  0 499M 0% /dev 
tmpfs   499M  0 499M 0% /sys/fs/cgroup 
tmpfs   897M 890M 7.0M 100% /etc/hosts 
shm    64M  0 64M 0% /dev/shm 

[email protected]:/# exit 
exit 

Animeshs-MacBook-Pro:docker_tests animesh$ 

我看起來虛擬機上的空間不足。

我想分配8GB磁盤空間和2GB RAM到celery-image1圖像。我怎樣才能做到這一點?

如果在創建容器時可以輸入任何命令行參數,那麼我也可以這樣做。

回答

0

如果運行$man docker run並查找「內存」,你可以找到:

-m, --memory="" 
     Memory limit (format: <number>[<unit>], where unit = b, k, m or g) 


    Allows you to constrain the memory available to a container. If the host supports swap memory, then the -m memory setting can be larger than physical RAM. If a limit 
    of 0 is specified (not using -m), the container's memory is not limited. The actual limit may be rounded up to a multiple of the operating system's page size (the 
    value would be very large, that's millions of trillions). 


    --memory-reservation="" 
     Memory soft limit (format: <number>[<unit>], where unit = b, k, m or g) 


    After setting memory reservation, when the system detects memory contention or low memory, containers are forced to restrict their consumption to their reservation. So 
    you should always set the value below --memory, otherwise the hard limit will take precedence. By default, memory reservation will be the same as memory limit. 


    --memory-swap="" 
     Total memory limit (memory + swap) 

這些都是你可以在運行$docker run設置的標誌。必須注意的是,您也可以爲CPU使用量設置一些限制。