AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 637038
Accepted
Peter Souter
Peter Souter
Asked: 2014-10-15 13:41:03 +0800 CST2014-10-15 13:41:03 +0800 CST 2014-10-15 13:41:03 +0800 CST

用烧杯测试 docker 实例

  • 772

我有一套针对 docker 主机运行的烧杯测试。

我不知道 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而不会出错的地方?

puppet
  • 2 2 个回答
  • 915 Views

2 个回答

  • Voted
  1. theterribletrivium
    2014-10-15T14:43:01+08:002014-10-15T14:43:01+08:00

    要在 Docker 中支持交换,您首先必须启用内存的 cgroup 管理并使用以下参数进行 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

    • 0
  2. Best Answer
    Peter Souter
    2014-10-17T02:08:43+08:002014-10-17T02:08:43+08:00

    所以我在#dockerfreenode 房间里询问,结果发现在 docker 容器中管理交换实际上是不可能的:

    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
    
    • 0

相关问题

  • 如何修复 Puppet 完全限定的参数路径错误?

  • puppet:修改配置文件后强制重启服务

  • 木偶模块资源

  • 傀儡主机名问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve