Skip to content

Commit

Permalink
Merge tag '1.2.0' into raspbian
Browse files Browse the repository at this point in the history
* tag '1.2.0': (46 commits)
  Bump 1.2.0
  Merge pull request docker#1278 from albers/completion-run-user
  Merge pull request docker#1261 from aanand/fix-vars-in-volume-paths
  Merge pull request docker#1202 from aanand/jenkins-script
  Merge pull request docker#1213 from moysesb/relative_build
  Merge pull request docker#1226 from aanand/merge-multi-value-options
  Merge pull request docker#1225 from aanand/fix-1222
  Fix regression in Dns and DnsSearch settings
  Fix volume merging when there's no explicit host path
  Fix service dict merging when only one dict has a volumes key
  Update docker-py and requests version ranges
  Revert "Remove restriction for requests version, update docker-py requirement"
  Revert "Use dev version of Docker"
  Revert "Add 'labels:' config option"
  Add 'labels:' config option
  Use dev version of Docker
  Make volume host paths relative to file, merge volumes when extending
  Implement `extends`
  Specify all HostConfig at create time
  Add build status \o/
  ...

Conflicts:
	Dockerfile
	README.md
	script/build-linux
  • Loading branch information
StefanScherer committed Apr 19, 2015
2 parents 043bb18 + 39ae91c commit 101dcae
Show file tree
Hide file tree
Showing 62 changed files with 2,200 additions and 503 deletions.
23 changes: 23 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
Change log
==========

1.2.0 (2015-04-16)
------------------

- `docker-compose.yml` now supports an `extends` option, which enables a service to inherit configuration from another service in another configuration file. This is really good for sharing common configuration between apps, or for configuring the same app for different environments. Here's the [documentation](https://github.com/docker/compose/blob/master/docs/yml.md#extends).

- When using Compose with a Swarm cluster, containers that depend on one another will be co-scheduled on the same node. This means that most Compose apps will now work out of the box, as long as they don't use `build`.

- Repeated invocations of `docker-compose up` when using Compose with a Swarm cluster now work reliably.

- Directories passed to `build`, filenames passed to `env_file` and volume host paths passed to `volumes` are now treated as relative to the *directory of the configuration file*, not the directory that `docker-compose` is being run in. In the majority of cases, those are the same, but if you use the `-f|--file` argument to specify a configuration file in another directory, **this is a breaking change**.

- A service can now share another service's network namespace with `net: container:<service>`.

- `volumes_from` and `net: container:<service>` entries are taken into account when resolving dependencies, so `docker-compose up <service>` will correctly start all dependencies of `<service>`.

- `docker-compose run` now accepts a `--user` argument to specify a user to run the command as, just like `docker run`.

- The `up`, `stop` and `restart` commands now accept a `--timeout` (or `-t`) argument to specify how long to wait when attempting to gracefully stop containers, just like `docker stop`.

- `docker-compose rm` now accepts `-f` as a shorthand for `--force`, just like `docker rm`.

Thanks, @abesto, @albers, @alunduil, @dnephin, @funkyfuture, @gilclark, @IanVS, @KingsleyKelly, @knutwalker, @thaJeztah and @vmalloc!

1.1.0 (2015-02-25)
------------------

Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ that should get you started.

## Running the test suite

Use the test script to run linting checks and then the full test suite:

$ script/test

Tests are run against a Docker daemon inside a container, so that we can test against multiple Docker versions. By default they'll run against only the latest Docker version - set the `DOCKER_VERSIONS` environment variable to "all" to run against all supported versions:

$ DOCKER_VERSIONS=all script/test

Arguments to `script/test` are passed through to the `nosetests` executable, so you can specify a test directory, file, module, class or method:

$ script/test tests/unit
$ script/test tests/unit/cli_test.py
$ script/test tests.integration.service_test
$ script/test tests.integration.service_test:ServiceTest.test_containers

## Building binaries

Linux:
Expand Down
26 changes: 25 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
FROM resin/rpi-raspbian:wheezy
RUN apt-get update -qq && apt-get install -qy python python-pip python-dev git && apt-get clean

RUN set -ex; \
apt-get update -qq; \
apt-get install -y \
python \
python-pip \
python-dev \
git \
apt-transport-https \
ca-certificates \
curl \
lxc \
iptables \
; \
rm -rf /var/lib/apt/lists/*

ENV ALL_DOCKER_VERSIONS 1.6.0-rc4

RUN set -ex; \
curl https://test.docker.com/builds/Linux/x86_64/docker-1.6.0-rc4 -o /usr/local/bin/docker-1.6.0-rc4; \
chmod +x /usr/local/bin/docker-1.6.0-rc4

# Set the default Docker to be run
RUN ln -s /usr/local/bin/docker-1.6.0-rc4 /usr/local/bin/docker

RUN useradd -d /home/user -m -s /bin/bash user
WORKDIR /code/

Expand Down
1 change: 0 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Aanand Prasad <[email protected]> (@aanand)
Ben Firshman <[email protected]> (@bfirsh)
Chris Corbyn <[email protected]> (@d11wtq)
Daniel Nephin <[email protected]> (@dnephin)
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include requirements.txt
include requirements-dev.txt
include tox.ini
include *.md
include contrib/completion/bash/docker-compose
recursive-include tests *
global-exclude *.pyc
global-exclude *.pyo
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
Docker Compose
==============

[![wercker status](https://app.wercker.com/status/d5dbac3907301c3d5ce735e2d5e95a5b/s/master "wercker status")](https://app.wercker.com/project/bykey/d5dbac3907301c3d5ce735e2d5e95a5b)

*(Previously known as Fig)*

Compose is a tool for defining and running complex applications with Docker.
Expand Down Expand Up @@ -53,11 +50,19 @@ Compose has commands for managing the whole lifecycle of your application:
Installation and documentation
------------------------------

To install Compose on Raspberry Pi with an installation of the [HypriotOS SD card image including Docker 1.5.0](http://blog.hypriot.com/heavily-armed-after-major-upgrade-raspberry-pi-with-docker-1-dot-5-0), run the following commands:
To install Compose on Raspberry Pi with an installation of the [HypriotOS SD card image including Docker 1.6.0](http://blog.hypriot.com/post/docker-1-6-is-finally-released-into-the-wild/), run the following commands:

```bash
curl -L https://github.com/hypriot/compose/releases/download/1.1.0-raspbian/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
```

Full documentation is available on [Fig's website](http://www.fig.sh/).
- Full documentation is available on [Docker's website](http://docs.docker.com/compose/).
- Hop into #docker-compose on Freenode if you have any questions.

Contributing
------------

[![Build Status](http://jenkins.dockerproject.com/buildStatus/icon?job=Compose Master)](http://jenkins.dockerproject.com/job/Compose%20Master/)

Want to help build Compose? Check out our [contributing documentation](https://github.com/docker/compose/blob/master/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion compose/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import unicode_literals
from .service import Service # noqa:flake8

__version__ = '1.1.0'
__version__ = '1.2.0'
15 changes: 4 additions & 11 deletions compose/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import logging
import os
import re
import yaml
import six

from .. import config
from ..project import Project
from ..service import ConfigError
from .docopt_command import DocoptCommand
Expand All @@ -25,7 +25,7 @@ class Command(DocoptCommand):
def dispatch(self, *args, **kwargs):
try:
super(Command, self).dispatch(*args, **kwargs)
except SSLError, e:
except SSLError as e:
raise errors.UserError('SSL error: %s' % e)
except ConnectionError:
if call_silently(['which', 'docker']) != 0:
Expand Down Expand Up @@ -69,18 +69,11 @@ def get_client(self, verbose=False):
return verbose_proxy.VerboseProxy('docker', client)
return client

def get_config(self, config_path):
try:
with open(config_path, 'r') as fh:
return yaml.safe_load(fh)
except IOError as e:
raise errors.UserError(six.text_type(e))

def get_project(self, config_path, project_name=None, verbose=False):
try:
return Project.from_config(
return Project.from_dicts(
self.get_project_name(config_path, project_name),
self.get_config(config_path),
config.load(config_path),
self.get_client(verbose=verbose))
except ConfigError as e:
raise errors.UserError(six.text_type(e))
Expand Down
2 changes: 1 addition & 1 deletion compose/cli/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def docker_client():
)

timeout = int(os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))
return Client(base_url=base_url, tls=tls_config, version='1.14', timeout=timeout)
return Client(base_url=base_url, tls=tls_config, version='1.15', timeout=timeout)
2 changes: 1 addition & 1 deletion compose/cli/log_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def no_color(text):
if monochrome:
color_fn = no_color
else:
color_fn = color_fns.next()
color_fn = next(color_fns)
generators.append(self._make_log_generator(container, color_fn))

return generators
Expand Down
93 changes: 57 additions & 36 deletions compose/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from __future__ import print_function
from __future__ import unicode_literals
from inspect import getdoc
from operator import attrgetter
import logging
import sys
import re
import signal
from operator import attrgetter
import sys

from inspect import getdoc
from docker.errors import APIError
import dockerpty

from .. import __version__
from ..project import NoSuchService, ConfigurationError
from ..service import BuildError, CannotBeScaledError
from ..config import parse_environment
from .command import Command
from .docopt_command import NoSuchCommand
from .errors import UserError
from .formatter import Formatter
from .log_printer import LogPrinter
from .utils import yesno

from docker.errors import APIError
from .errors import UserError
from .docopt_command import NoSuchCommand

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -238,8 +238,8 @@ def rm(self, project, options):
Usage: rm [options] [SERVICE...]
Options:
--force Don't ask to confirm removal
-v Remove volumes associated with containers
-f, --force Don't ask to confirm removal
-v Remove volumes associated with containers
"""
all_containers = project.containers(service_names=options['SERVICE'], stopped=True)
stopped_containers = [c for c in all_containers if not c.is_running]
Expand Down Expand Up @@ -276,6 +276,7 @@ def run(self, project, options):
new container name.
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-u, --user="" Run as specified username or uid
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
--service-ports Run command with the service's ports enabled and mapped
Expand All @@ -293,7 +294,7 @@ def run(self, project, options):
if len(deps) > 0:
project.up(
service_names=deps,
start_links=True,
start_deps=True,
recreate=False,
insecure_registry=insecure_registry,
detach=options['-d']
Expand All @@ -316,28 +317,31 @@ def run(self, project, options):
}

if options['-e']:
for option in options['-e']:
if 'environment' not in service.options:
service.options['environment'] = {}
k, v = option.split('=', 1)
service.options['environment'][k] = v
# Merge environment from config with -e command line
container_options['environment'] = dict(
parse_environment(service.options.get('environment')),
**parse_environment(options['-e']))

if options['--entrypoint']:
container_options['entrypoint'] = options.get('--entrypoint')

if options['--user']:
container_options['user'] = options.get('--user')

if not options['--service-ports']:
container_options['ports'] = []

container = service.create_container(
one_off=True,
insecure_registry=insecure_registry,
**container_options
)

service_ports = None
if options['--service-ports']:
service_ports = service.options['ports']
if options['-d']:
service.start_container(container, ports=service_ports, one_off=True)
service.start_container(container)
print(container.name)
else:
service.start_container(container, ports=service_ports, one_off=True)
service.start_container(container)
dockerpty.start(project.client, container.id, interactive=not options['-T'])
exit_code = container.wait()
if options['--rm']:
Expand Down Expand Up @@ -389,17 +393,29 @@ def stop(self, project, options):
They can be started again with `docker-compose start`.
Usage: stop [SERVICE...]
Usage: stop [options] [SERVICE...]
Options:
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds.
(default: 10)
"""
project.stop(service_names=options['SERVICE'])
timeout = options.get('--timeout')
params = {} if timeout is None else {'timeout': int(timeout)}
project.stop(service_names=options['SERVICE'], **params)

def restart(self, project, options):
"""
Restart running containers.
Usage: restart [SERVICE...]
Usage: restart [options] [SERVICE...]
Options:
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds.
(default: 10)
"""
project.restart(service_names=options['SERVICE'])
timeout = options.get('--timeout')
params = {} if timeout is None else {'timeout': int(timeout)}
project.restart(service_names=options['SERVICE'], **params)

def up(self, project, options):
"""
Expand All @@ -418,30 +434,33 @@ def up(self, project, options):
Usage: up [options] [SERVICE...]
Options:
--allow-insecure-ssl Allow insecure connections to the docker
registry
-d Detached mode: Run containers in the background,
print new container names.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--no-recreate If containers already exist, don't recreate them.
--no-build Don't build an image, even if it's missing
--allow-insecure-ssl Allow insecure connections to the docker
registry
-d Detached mode: Run containers in the background,
print new container names.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--no-recreate If containers already exist, don't recreate them.
--no-build Don't build an image, even if it's missing
-t, --timeout TIMEOUT When attached, use this timeout in seconds
for the shutdown. (default: 10)
"""
insecure_registry = options['--allow-insecure-ssl']
detached = options['-d']

monochrome = options['--no-color']

start_links = not options['--no-deps']
start_deps = not options['--no-deps']
recreate = not options['--no-recreate']
service_names = options['SERVICE']

project.up(
service_names=service_names,
start_links=start_links,
start_deps=start_deps,
recreate=recreate,
insecure_registry=insecure_registry,
detach=options['-d'],
detach=detached,
do_build=not options['--no-build'],
)

Expand All @@ -460,7 +479,9 @@ def handler(signal, frame):
signal.signal(signal.SIGINT, handler)

print("Gracefully stopping... (press Ctrl+C again to force)")
project.stop(service_names=service_names)
timeout = options.get('--timeout')
params = {} if timeout is None else {'timeout': int(timeout)}
project.stop(service_names=service_names, **params)


def list_containers(containers):
Expand Down
Loading

0 comments on commit 101dcae

Please sign in to comment.