运行 docker 运行 主厨
Running docker run in Chef
我希望让 Chef 管理 运行 docker 个容器。但是我不确定如何前进。这是我今天使用的 docker run
命令,我想让它对厨师友好,并将其移至我的食谱中:
docker run --name=nginx--restart=unless-stopped -p 443:443 -p 80:80 --privileged=true -v /etc/php:/conf/stack -v /var/www/html -d repository.com/nginx:v1.5.3
有什么提示或想法吗?
您可以使用来自 Chef's Supermarket 的 "official" Docker 食谱 - https://supermarket.chef.io/cookbooks/docker
那么作为一个例子你可以这样做:
# Pull latest image
docker_image 'nginx' do
tag 'latest'
action :pull
notifies :redeploy, 'docker_container[my_nginx]'
end
# Run container mapping containers port 80 to the host's port 80
docker_container 'my_nginx' do
repo 'nginx'
tag 'latest'
port '80:80'
host_name 'www'
domain_name 'computers.biz'
env 'FOO=bar'
volumes [ '/some/local/files/:/etc/nginx/conf.d' ]
end
我希望让 Chef 管理 运行 docker 个容器。但是我不确定如何前进。这是我今天使用的 docker run
命令,我想让它对厨师友好,并将其移至我的食谱中:
docker run --name=nginx--restart=unless-stopped -p 443:443 -p 80:80 --privileged=true -v /etc/php:/conf/stack -v /var/www/html -d repository.com/nginx:v1.5.3
有什么提示或想法吗?
您可以使用来自 Chef's Supermarket 的 "official" Docker 食谱 - https://supermarket.chef.io/cookbooks/docker
那么作为一个例子你可以这样做:
# Pull latest image
docker_image 'nginx' do
tag 'latest'
action :pull
notifies :redeploy, 'docker_container[my_nginx]'
end
# Run container mapping containers port 80 to the host's port 80
docker_container 'my_nginx' do
repo 'nginx'
tag 'latest'
port '80:80'
host_name 'www'
domain_name 'computers.biz'
env 'FOO=bar'
volumes [ '/some/local/files/:/etc/nginx/conf.d' ]
end