用烧杯testingdocker实例

我有一套运行在docker主机上的Beakertesting。

我不知道Docker如何处理交换文件的复杂性,但它似乎并不喜欢它。

Puppet代码如下所示:

exec { 'Create swap file': command => "/bin/dd if=/dev/zero of=${swapfile} bs=1M count=${swapfilesize_mb}", creates => $swapfile, } exec { 'Attach swap file': command => "/sbin/mkswap ${swapfile} && /sbin/swapon ${swapfile}", require => Exec['Create swap file'], unless => "/sbin/swapon -s | grep ${swapfile}", } if $add_mount { mount { 'swap': ensure => present, fstype => swap, device => $swapfile, dump => 0, pass => 0, require => Exec['Attach swap file'], } } 

并且错误消息如下所示:

 Info: Loading facts Notice: Compiled catalog for centos-6-x64 in environment production in 0.22 seconds Info: Applying configuration version '1411345072' Notice: /Stage[main]/Swap_file/Exec[Create swap file]/returns: executed successfully Notice: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: mkswap: /tmp/swapfile: warning: don't erase bootbits sectors Notice: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: on whole disk. Use -f to force. Notice: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: Setting up swapspace version 1, size = 5116 KiB Notice: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: no label, UUID=ceb75f7d-ae8b-4781-bd1b-4123bec9bcf1 Notice: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: swapon: /tmp/swapfile: swapon failed: Input/output error Error: /sbin/mkswap /tmp/swapfile && /sbin/swapon /tmp/swapfile returned 255 instead of one of [0] Error: /Stage[main]/Swap_file/Exec[Attach swap file]/returns: change from notrun to 0 failed: /sbin/mkswap /tmp/swapfile && /sbin/swapon /tmp/swapfile returned 255 instead of one of [0] Notice: /Stage[main]/Swap_file/Mount[swap]: Dependency Exec[Attach swap file] has failures: true Warning: /Stage[main]/Swap_file/Mount[swap]: Skipping because of failed dependencies Notice: Finished catalog run in 0.26 seconds 

所以基本上,我如何设置docker集装箱到哪里我可以运行swapon而不会出错?

要在Docker中支持交换,首先必须启用内存的cgrouppipe理,并使用以下参数进行wap:cgroup_enable = memory swapaccount = 1。

如果你正在使用grub,它应该在/ etc / default / grub中,而将其添加到的行应该是GRUB_CMDLINE_LINUX或GRUB_CMDLINE_LINUX_DEFAULT。 做这个更改之后,运行sudo update-grub并重启。 更多的细节在这里: http : //docker.readthedocs.org/en/v0.7.3/installation/kernel/

让我知道如果这没有帮助,我们可以走得更远。 如果这不起作用,那么尝试通过在shell中启动容器来手动运行这些命令。 运行这个来获得一个交互式shell并运行命令:docker run -t -i image_name / bin / bash

所以我在#docker freenode房间里问了#docker ,结果是在#docker容器中pipe理swap是不太可能的:

 10:44 AM <petems> cnf: How do I make it so that in a docker container for say, centos 6, I can run swap commands? Is that possible? 10:44 AM <cnf> petems: you can NOT swapon for _only_ the container, sorry 10:45 AM <cnf> petems: docker is NOT a VM