2014-04-15 20:53:12 -04:00
|
|
|
page_title: Chef Usage
|
|
|
|
page_description: Installation and using Docker via Chef
|
|
|
|
page_keywords: chef, installation, usage, docker, documentation
|
|
|
|
|
|
|
|
# Using Chef
|
|
|
|
|
2014-04-18 16:21:55 -04:00
|
|
|
> **Note**:
|
|
|
|
> Please note this is a community contributed installation path. The only
|
2014-04-23 16:48:28 -04:00
|
|
|
> `official` installation is using the
|
2014-12-15 23:25:37 -05:00
|
|
|
> [*Ubuntu*](/installation/ubuntulinux) installation
|
2014-04-18 16:21:55 -04:00
|
|
|
> path. This version may sometimes be out of date.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
2014-04-23 16:48:28 -04:00
|
|
|
To use this guide you'll need a working installation of
|
2014-04-15 20:53:12 -04:00
|
|
|
[Chef](http://www.getchef.com/). This cookbook supports a variety of
|
|
|
|
operating systems.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
The cookbook is available on the [Chef Community
|
2014-05-14 13:22:49 -04:00
|
|
|
Site](http://community.opscode.com/cookbooks/docker) and can be
|
|
|
|
installed using your favorite cookbook dependency manager.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
The source can be found on
|
|
|
|
[GitHub](https://github.com/bflad/chef-docker).
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
The cookbook provides recipes for installing Docker, configuring init
|
|
|
|
for Docker, and resources for managing images and containers. It
|
|
|
|
supports almost all Docker functionality.
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
include_recipe 'docker'
|
|
|
|
|
|
|
|
### Images
|
|
|
|
|
|
|
|
The next step is to pull a Docker image. For this, we have a resource:
|
|
|
|
|
|
|
|
docker_image 'samalba/docker-registry'
|
|
|
|
|
|
|
|
This is equivalent to running:
|
|
|
|
|
2014-09-15 21:49:05 -04:00
|
|
|
$ sudo docker pull samalba/docker-registry
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
There are attributes available to control how long the cookbook will
|
|
|
|
allow for downloading (5 minute default).
|
|
|
|
|
|
|
|
To remove images you no longer need:
|
|
|
|
|
|
|
|
docker_image 'samalba/docker-registry' do
|
|
|
|
action :remove
|
|
|
|
end
|
|
|
|
|
|
|
|
### Containers
|
|
|
|
|
|
|
|
Now you have an image where you can run commands within a container
|
|
|
|
managed by Docker.
|
|
|
|
|
|
|
|
docker_container 'samalba/docker-registry' do
|
|
|
|
detach true
|
|
|
|
port '5000:5000'
|
|
|
|
env 'SETTINGS_FLAVOR=local'
|
|
|
|
volume '/mnt/docker:/docker-storage'
|
|
|
|
end
|
|
|
|
|
|
|
|
This is equivalent to running the following command, but under upstart:
|
|
|
|
|
2014-09-15 21:49:05 -04:00
|
|
|
$ sudo docker run --detach=true --publish='5000:5000' --env='SETTINGS_FLAVOR=local' --volume='/mnt/docker:/docker-storage' samalba/docker-registry
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
The resources will accept a single string or an array of values for any
|
2014-05-14 13:22:49 -04:00
|
|
|
Docker flags that allow multiple values.
|