diff --git a/compose/config/config.py b/compose/config/config.py index 9f8a50c62..aab78be5f 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -918,6 +918,11 @@ def convert_restart_policy(name): def translate_deploy_keys_to_container_config(service_dict): + if 'credential_spec' in service_dict: + del service_dict['credential_spec'] + if 'configs' in service_dict: + del service_dict['configs'] + if 'deploy' not in service_dict: return service_dict, [] @@ -946,10 +951,6 @@ def translate_deploy_keys_to_container_config(service_dict): ) del service_dict['deploy'] - if 'credential_spec' in service_dict: - del service_dict['credential_spec'] - if 'configs' in service_dict: - del service_dict['configs'] return service_dict, ignored_keys diff --git a/compose/config/serialize.py b/compose/config/serialize.py index c0cf35c1b..ccddbf532 100644 --- a/compose/config/serialize.py +++ b/compose/config/serialize.py @@ -80,6 +80,10 @@ def denormalize_config(config, image_digests=None): elif 'external' in conf: conf['external'] = True + if 'attachable' in conf and config.version < V3_2: + # For compatibility mode, this option is invalid in v2 + del conf['attachable'] + return result diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 075705804..43e8fa822 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -481,6 +481,7 @@ class CLITestCase(DockerClientTestCase): assert yaml.load(result.stdout) == { 'version': '2.3', 'volumes': {'foo': {'driver': 'default'}}, + 'networks': {'bar': {}}, 'services': { 'foo': { 'command': '/bin/true', @@ -490,9 +491,10 @@ class CLITestCase(DockerClientTestCase): 'mem_limit': '300M', 'mem_reservation': '100M', 'cpus': 0.7, - 'volumes': ['foo:/bar:rw'] + 'volumes': ['foo:/bar:rw'], + 'networks': {'bar': None}, } - } + }, } def test_ps(self): diff --git a/tests/fixtures/compatibility-mode/docker-compose.yml b/tests/fixtures/compatibility-mode/docker-compose.yml index aac6fd4cb..8187b110c 100644 --- a/tests/fixtures/compatibility-mode/docker-compose.yml +++ b/tests/fixtures/compatibility-mode/docker-compose.yml @@ -16,7 +16,13 @@ services: memory: 100M volumes: - foo:/bar + networks: + - bar volumes: foo: driver: default + +networks: + bar: + attachable: true