Skip to content

JasonBoyles/docker

 
 

Repository files navigation

Description

This is a template for deploying Docker container on a single Linux server.

Requirements

  • A Heat provider that supports the following:
    • OS::Nova::KeyPair
    • Rackspace::Cloud::Server
    • OS::Heat::ChefSolo
  • An OpenStack username, password, and tenant id.
  • python-heatclient >= v0.2.8:
pip install python-heatclient

We recommend installing the client within a Python virtual environment.

Example Usage

Here is an example of how to deploy this template using the python-heatclient:

heat --os-username <OS-USERNAME> --os-password <OS-PASSWORD> --os-tenant-id \
  <TENANT-ID> --os-auth-url https://identity.api.rackspacecloud.com/v2.0/ \
  stack-create Docker-Stack -f docker-server.yaml \
  -P server_hostname=docker-server
  • For UK customers, use https://lon.identity.api.rackspacecloud.com/v2.0/ as the --os-auth-url.

Optionally, set environmental variables to avoid needing to provide these values every time a call is made:

export OS_USERNAME=<USERNAME>
export OS_PASSWORD=<PASSWORD>
export OS_TENANT_ID=<TENANT-ID>
export OS_AUTH_URL=<AUTH-URL>

Parameters

Parameters can be replaced with your own values when standing up a stack. Use the -P flag to specify a custom parameter.

  • server_hostname: Server Name (Default: docker)
  • image: Server image used for all servers that are created as a part of this deployment. (Default: Ubuntu 14.04 LTS (Trusty Tahr))
  • docker_host_port: Port to expose on Docker host. (Default: 8080)
  • docker_container_port: Port to expose on Docker container. (Default: 8080)
  • docker_command_params: Parameters to pass to command in Docker container. (Default: 30)
  • docker_tag: Docker image tag to deploy. (Default: latest)
  • flavor: Rackspace Cloud Server flavor to use. The size is based on the amount of RAM for the provisioned server. (Default: 2 GB Performance)
  • docker_command_name: Command to run in Docker container. (Default: sleep)
  • chef_version: Version of chef client to use (Default: 11.12.8)
  • docker_image: Docker image to deploy. (Default: busybox)
  • kitchen: URL for a git repo containing required cookbooks (Default: https://github.com/rackspace-orchestration-templates/docker)

Outputs

Once a stack comes online, use heat output-list to see all available outputs. Use heat output-show <OUTPUT NAME> to get the value fo a specific output.

  • private_key: SSH private that can be used to login as root to the server.
  • server_ip: Public IP address of the Docker server

For multi-line values, the response will come in an escaped form. To get rid of the escapes, use echo -e '<STRING>' > file.txt. For vim users, a substitution can be done within a file using %s/\\n/\r/g.

Stack Details

Getting Started

If you're new to Docker, check out Getting started with docker. The getting started document will help guide you through the initial steps of managing Containers.

Docker Deployment Notes

If a container was defined to be installed, this deployment will attempt to install it from the Docker index.

If a container port was specified, but no host port, Docker will map the container port to a random port on your public interfaces. To see determine the mapping, find the ID of your container and then use the inspect command to find the PortBindings. By using 'ps' and 'inspect', here is how we would find a mapping:

root@docker:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e33daf024abc        ubuntu:12.04        sleep 60            16 minutes ago      Exit 0                                  ubuntu

root@docker:~# docker inspect e33daf024abc
[{
    "ID": "e33daf024abccb44cbc7df840a172a5a89bf8e594ee98b79efa91b54f99625ac",
    "Created": "2014-02-03T20:05:17.490688626Z",
    "Path": "sleep",
    "Args": [
        "60"
    ],
    "Config": {
        "Hostname": "e33daf024abc",
        "Domainname": "",
        "User": "",
        "Memory": 0,
        "MemorySwap": 0,
        "CpuShares": 0,
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": {
            "8888/tcp": {}
        },
    ...
    ...
    "HostConfig": {
        "Binds": null,
        "ContainerIDFile": "/var/run/ubuntu.cid",
        "LxcConf": [],
        "Privileged": false,
        "PortBindings": {
            "8888/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "49153"
                }
            ]
        },
        "Links": null,
        "PublishAllPorts": false
    }
}]
root@docker:~#

Additional Modules

There are hundreds of images that have been created by an engaged developer community. You can browse the images on the docker registry.

Logging in via SSH

The private key provided in the passwords section can be used to login as root via SSH. We have an article on how to use these keys with Mac OS X and Linux as well as Windows using PuTTY.

Contributing

There are substantial changes still happening within the OpenStack Heat project. Template contribution guidelines will be drafted in the near future.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Heat template to setup Docker on a Cloud Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 99.9%
  • Python 0.1%