Skip to content

Commit 6f6fb73

Browse files
committed
Merge remote-tracking branch 'origin2/master'
Conflicts: compose/service.py requirements.txt
2 parents d32fce2 + c802245 commit 6f6fb73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1073
-429
lines changed

CHANGES.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
Change log
22
==========
33

4+
1.2.0 (2015-04-16)
5+
------------------
6+
7+
- `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).
8+
9+
- 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`.
10+
11+
- Repeated invocations of `docker-compose up` when using Compose with a Swarm cluster now work reliably.
12+
13+
- 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**.
14+
15+
- A service can now share another service's network namespace with `net: container:<service>`.
16+
17+
- `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>`.
18+
19+
- `docker-compose run` now accepts a `--user` argument to specify a user to run the command as, just like `docker run`.
20+
21+
- 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`.
22+
23+
- `docker-compose rm` now accepts `-f` as a shorthand for `--force`, just like `docker rm`.
24+
25+
Thanks, @abesto, @albers, @alunduil, @dnephin, @funkyfuture, @gilclark, @IanVS, @KingsleyKelly, @knutwalker, @thaJeztah and @vmalloc!
26+
427
1.1.0 (2015-02-25)
528
------------------
629

CONTRIBUTING.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ that should get you started.
3131

3232
## Running the test suite
3333

34-
Use the test script to run DCO check, linting checks and then the full test
35-
suite against different Python interpreters:
34+
Use the test script to run linting checks and then the full test suite against
35+
different Python interpreters:
3636

3737
$ script/test
3838

@@ -51,8 +51,6 @@ you can specify a test directory, file, module, class or method:
5151
$ script/test tests.integration.service_test
5252
$ script/test tests.integration.service_test:ServiceTest.test_containers
5353

54-
Before pushing a commit you can check the DCO by invoking `script/validate-dco`.
55-
5654
## Building binaries
5755

5856
Linux:

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ RUN set -ex; \
1515
; \
1616
rm -rf /var/lib/apt/lists/*
1717

18-
ENV ALL_DOCKER_VERSIONS 1.6.0-rc4
18+
ENV ALL_DOCKER_VERSIONS 1.6.0
1919

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

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

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

README.md

+16-25
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,24 @@ recommend that you use it in production yet.
1212

1313
Using Compose is basically a three-step process.
1414

15-
First, you define your app's environment with a `Dockerfile` so it can be
16-
reproduced anywhere:
17-
18-
```Dockerfile
19-
FROM python:2.7
20-
WORKDIR /code
21-
ADD requirements.txt /code/
22-
RUN pip install -r requirements.txt
23-
ADD . /code
24-
CMD python app.py
25-
```
26-
27-
Next, you define the services that make up your app in `docker-compose.yml` so
15+
1. Define your app's environment with a `Dockerfile` so it can be
16+
reproduced anywhere.
17+
2. Define the services that make up your app in `docker-compose.yml` so
2818
they can be run together in an isolated environment:
19+
3. Lastly, run `docker-compose up` and Compose will start and run your entire app.
2920

30-
```yaml
31-
web:
32-
build: .
33-
links:
34-
- db
35-
ports:
36-
- "8000:8000"
37-
db:
38-
image: postgres
39-
```
21+
A `docker-compose.yml` looks like this:
4022

41-
Lastly, run `docker-compose up` and Compose will start and run your entire app.
23+
web:
24+
build: .
25+
ports:
26+
- "5000:5000"
27+
volumes:
28+
- .:/code
29+
links:
30+
- redis
31+
redis:
32+
image: redis
4233

4334
Compose has commands for managing the whole lifecycle of your application:
4435

@@ -51,7 +42,7 @@ Installation and documentation
5142
------------------------------
5243

5344
- Full documentation is available on [Docker's website](http://docs.docker.com/compose/).
54-
- Hop into #docker-compose on Freenode if you have any questions.
45+
- If you have any questions, you can talk in real-time with other developers in the #docker-compose IRC channel on Freenode. [Click here to join using IRCCloud.](https://www.irccloud.com/invite?hostname=irc.freenode.net&channel=%23docker-compose)
5546

5647
Contributing
5748
------------

compose/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from __future__ import unicode_literals
22
from .service import Service # noqa:flake8
33

4-
__version__ = '1.1.0'
4+
__version__ = '1.3.0dev'

compose/cli/command.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@
1010
from ..project import Project
1111
from ..service import ConfigError
1212
from .docopt_command import DocoptCommand
13-
from .utils import call_silently, is_mac, is_ubuntu
13+
from .utils import call_silently, is_mac, is_ubuntu, find_candidates_in_parent_dirs
1414
from .docker_client import docker_client
1515
from . import verbose_proxy
1616
from . import errors
1717
from .. import __version__
1818

1919
log = logging.getLogger(__name__)
2020

21+
SUPPORTED_FILENAMES = [
22+
'docker-compose.yml',
23+
'docker-compose.yaml',
24+
'fig.yml',
25+
'fig.yaml',
26+
]
27+
2128

2229
class Command(DocoptCommand):
2330
base_dir = '.'
@@ -100,20 +107,10 @@ def get_config_path(self, file_path=None):
100107
if file_path:
101108
return os.path.join(self.base_dir, file_path)
102109

103-
supported_filenames = [
104-
'docker-compose.yml',
105-
'docker-compose.yaml',
106-
'fig.yml',
107-
'fig.yaml',
108-
]
109-
110-
def expand(filename):
111-
return os.path.join(self.base_dir, filename)
112-
113-
candidates = [filename for filename in supported_filenames if os.path.exists(expand(filename))]
110+
(candidates, path) = find_candidates_in_parent_dirs(SUPPORTED_FILENAMES, self.base_dir)
114111

115112
if len(candidates) == 0:
116-
raise errors.ComposeFileNotFound(supported_filenames)
113+
raise errors.ComposeFileNotFound(SUPPORTED_FILENAMES)
117114

118115
winner = candidates[0]
119116

@@ -130,4 +127,4 @@ def expand(filename):
130127
log.warning("%s is deprecated and will not be supported in future. "
131128
"Please rename your config file to docker-compose.yml\n" % winner)
132129

133-
return expand(winner)
130+
return os.path.join(path, winner)

compose/cli/docker_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ def docker_client():
3232
)
3333

3434
timeout = int(os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))
35-
return Client(base_url=base_url, tls=tls_config, version='1.15', timeout=timeout)
35+
return Client(base_url=base_url, tls=tls_config, version='1.18', timeout=timeout)

compose/cli/errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, url):
5858
class ComposeFileNotFound(UserError):
5959
def __init__(self, supported_filenames):
6060
super(ComposeFileNotFound, self).__init__("""
61-
Can't find a suitable configuration file. Are you in the right directory?
61+
Can't find a suitable configuration file in this directory or any parent. Are you in the right directory?
6262
6363
Supported filenames: %s
6464
""" % ", ".join(supported_filenames))

compose/cli/main.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ class TopLevelCommand(Command):
7575
docker-compose -h|--help
7676
7777
Options:
78-
--verbose Show more output
79-
--version Print version and exit
8078
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
8179
-p, --project-name NAME Specify an alternate project name (default: directory name)
80+
--verbose Show more output
81+
-v, --version Print version and exit
8282
8383
Commands:
8484
build Build or rebuild services
@@ -88,12 +88,12 @@ class TopLevelCommand(Command):
8888
port Print the public port for a port binding
8989
ps List containers
9090
pull Pulls service images
91+
restart Restart services
9192
rm Remove stopped containers
9293
run Run a one-off command
9394
scale Set number of containers for a service
9495
start Start services
9596
stop Stop services
96-
restart Restart services
9797
up Create and start containers
9898
9999
"""
@@ -108,7 +108,7 @@ def build(self, project, options):
108108
109109
Services are built once and then tagged as `project_service`,
110110
e.g. `composetest_db`. If you change a service's `Dockerfile` or the
111-
contents of its build directory, you can run `compose build` to rebuild it.
111+
contents of its build directory, you can run `docker-compose build` to rebuild it.
112112
113113
Usage: build [options] [SERVICE...]
114114
@@ -317,14 +317,14 @@ def run(self, project, options):
317317
}
318318

319319
if options['-e']:
320-
# Merge environment from config with -e command line
321-
container_options['environment'] = dict(
322-
parse_environment(service.options.get('environment')),
323-
**parse_environment(options['-e']))
320+
container_options['environment'] = parse_environment(options['-e'])
324321

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

325+
if options['--rm']:
326+
container_options['restart'] = None
327+
328328
if options['--user']:
329329
container_options['user'] = options.get('--user')
330330

compose/cli/utils.py

+19
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ def mkdir(path, permissions=0o700):
6262
return path
6363

6464

65+
def find_candidates_in_parent_dirs(filenames, path):
66+
"""
67+
Given a directory path to start, looks for filenames in the
68+
directory, and then each parent directory successively,
69+
until found.
70+
71+
Returns tuple (candidates, path).
72+
"""
73+
candidates = [filename for filename in filenames
74+
if os.path.exists(os.path.join(path, filename))]
75+
76+
if len(candidates) == 0:
77+
parent_dir = os.path.join(path, '..')
78+
if os.path.abspath(parent_dir) != os.path.abspath(path):
79+
return find_candidates_in_parent_dirs(filenames, parent_dir)
80+
81+
return (candidates, path)
82+
83+
6584
def split_buffer(reader, separator):
6685
"""
6786
Given a generator which yields strings and a separator string,

0 commit comments

Comments
 (0)