and can be easily adapted to other cloud providers that may provide an Atomic tem‐
plate:
#!/usr/bin/env python
import os
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
ACCESS_ID = os.getenv('AWSAccessKeyId')
SECRET_KEY = os.getenv('AWSSecretKey')
IMAGE_ID = 'ami-dd3fb0aa'
SIZE_ID = 'm3.medium'
cls = get_driver(Provider.EC2_EU_WEST)
driver = cls(ACCESS_ID, SECRET_KEY)
sizes = driver.list_sizes()
images = driver.list_images()
size = [s for s in sizes if s.id == SIZE_ID][0]
image = [i for i in images if i.id == IMAGE_ID][0]
# Reads cloud config file
userdata = "\n".join(open('./cloud.cfg').readlines())
# Replace the name of
the ssh key pair with yours
# You will need to open SSH port 22 on your default security group
# This also assumes a keypair named 'atomic'
name = "atomic"
node = driver.create_node(name=name, image=image,size=size,ex_keyname='atomic', \
ex_userdata=userdata)
snap, ip = driver.wait_until_running(nodes=[node])[0]
print ip[0]
As mentioned as comments in the script, you will need to have a security group with
port 22 open,
an SSH key pair called
atomic
, and a
cloud.cfg
file that contains your
user data.
6.8 Running Docker on Ubuntu Core Snappy in a Snap
Problem
You would like to take the new Ubuntu Core Snappy for a test drive. You do not want
to mess with
connecting to a public cloud, do not want to install an ISO by hand, and
want to avoid reading as much documentation as possible. You want Snappy in a
snap.
6.8 Running Docker on Ubuntu Core Snappy in a Snap | 185
Solution
I provide a Vagrantfile for starting an Ubuntu Core Snappy virtual machine on your
local host. Clone the repository accompanying this
book if you have not done so
already. Then head to the
ch06/snappy
directory and
vagrant up
. Finally,
ssh
to the
VM and use Docker:
$ git clone https://github.com/how2dock/docbook.git
$ cd docbook/ch06/snappy
$ vagrant up
$ vagrant ssh
$
snappy info
release: ubuntu-core/devel
frameworks: docker
apps:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
This process downloads a public
Vagrant box from Atlas
komljen/
ubuntu-snappy
. If you do not trust this box, do not use it.
Ubuntu Snappy is in alpha release and should be considered a tech‐
nical preview.
Discussion
On December 9, 2014, Canonical
announced
Snappy
, a new Linux distribution based
on
Ubuntu Core, with transactional updates. It is a significant departure from the
package and application management model used thus far in mainstream Ubuntu
server and desktop.
Ubuntu
Core
is a minimal root filesystem that provides enough operating system
capabilities to install packages. With Snappy, you get transactional updates and roll‐
back on Ubuntu Core. This is achieved through an image-based
workflow inherited
from the Ubuntu phone application management system. This means (among other
things) that
apt-get
does not work on
snappy
.
This makes Docker the perfect application framework on Snappy. Docker is installed
as a
framework
that can be updated and rolled back as atomic transactions.
Follow this walk-through:
Do'stlaringiz bilan baham: