Let's prepare such VM using Vagrant. In this article I show how to set-up our Vagrant box and connect it to Docker Cloud account. I use Ansible for provisioning VM box.
0. Get the code
All needed files can be downloaded from Git Hub repository.
Clone it using the following command:
git clone email@example.com:pozgo/vagrant-docker-cloud.git
Here's how the file structure of cloned repository looks like:
. ├── LICENSE ├── README.md ├── Vagrantfile # Vagrant config file. (Set RAM and CPU number) ├── group_vars │ └── all # Contains username and API key ├── provision.yml # Ansible provisioning settings └── roles └── docker-cloud ├── tasks │ └── main.yml └── templates └── environment.j2
1. Vagrant settings
In the Vagrantfile user can edit settings regarding CPU's and RAM memory that virtual machine should use. Default is set to use 1 CPU and 4GB of RAM memory.
Content of default file:
Settings that should be changed:
v.memory = 4096 # set RAM memory v.cpus = 1 # set number of CPU's ip = "192.168.1.30" # set VM IP address bridge: 'en0: Ethernet' # set to match your OS NIC interface for bridge should work on
2. Docker Cloud API Key (environmental variables)
Docker Cloud needs to have active API Key available on users account. To be able to do that we need to log in into Docker Cloud user panel and add it.
First log in into user panel. And select "Account Info" then "API keys" and "Create API Key"
Now group_vars/all variables file can be edited. By doing this Ansible will update /etc/environment file and install Docker Cloud agent with provided credentials.
├── group_vars │ └── all
Chage username and API key to match newly created API key.
It should like something like this:
--- docker_cloud_username: polinux docker_cloud_api_key: c0bbb178-c4e5-46b8-8391-e85145735e94
Start deployment with:
Output should something like in video below. Waint until all provisioning is finished and then you should see your new node in Docker Cloud node section
All Done! Docker Cloud have new node added and you can easily deploy using cloud-config inside Docker Cloud.