【问题标题】:Linking 2 docker containers in chef recipe在厨师食谱中链接 2 个 docker 容器
【发布时间】:2018-05-30 02:07:47
【问题描述】:

我正在尝试使用厨师食谱来实现该命令的功能:

docker run -d --name=nginx --restart=unless-stopped -p 80:80 -p 443:443 -v /etc/test/test.cert:/etc/test/test.cert -v /etc/test/test.key:/etc/test/test.key -v /etc/nginx/conf.d/nginx_ssl_conf.conf:/etc/nginx/conf.d/default.conf --link=rancher-server nginx

这是我到目前为止所想出的。但我仍然无法链接这两个容器:

docker_image 'nginx' do
  tag 'latest'
  action :pull
end

docker_container 'my_nginx' do
  repo 'nginx'
  tag 'latest'
  port ['80:80', '443:443']
  volumes [ '/etc/test/test.cert:/etc/test/test.cert', '/etc/test/test.key:/etc/test/test.key', '/etc/nginx/conf.d/nginx_ssl_conf.conf:/etc/nginx/conf.d/default.conf' ]
  links ['rancher-server:nginx']
  subscribes :run, 'docker_image[nginx]'
end

有什么想法吗?建议?

【问题讨论】:

    标签: nginx chef-infra docker-container


    【解决方案1】:

    有一个links 属性,它接受一个链接数组。如果您搜索“管理容器链接”,则有一个示例 in the README

    【讨论】:

    • 我没有看到任何变化,你能说得更具体点吗?
    • 啊,就是这样。
    • 这似乎不起作用。当我运行“docker ps -a”时,nginx 容器的状态是“Exited (1) 26 seconds ago”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-01
    • 2021-10-31
    • 2014-12-05
    相关资源
    最近更新 更多