mirror of
https://github.com/docker/compose.git
synced 2025-07-22 13:14:29 +02:00
Update for links, external_links, network_mode
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
9249ec62c2
commit
36a10f8dd5
@ -20,20 +20,45 @@ def migrate(content):
|
|||||||
data = ruamel.yaml.load(content, ruamel.yaml.RoundTripLoader)
|
data = ruamel.yaml.load(content, ruamel.yaml.RoundTripLoader)
|
||||||
|
|
||||||
service_names = data.keys()
|
service_names = data.keys()
|
||||||
|
|
||||||
for name, service in data.items():
|
for name, service in data.items():
|
||||||
# remove links and external links
|
links = service.get('links')
|
||||||
service.pop('links', None)
|
if links:
|
||||||
external_links = service.pop('external_links', None)
|
example_service = links[0].partition(':')[0]
|
||||||
|
log.warn(
|
||||||
|
"Service {name} has links, which no longer create environment "
|
||||||
|
"variables such as {example_service_upper}_PORT. "
|
||||||
|
"If you are using those in your application code, you should "
|
||||||
|
"instead connect directly to the hostname, e.g. "
|
||||||
|
"'{example_service}'."
|
||||||
|
.format(name=name, example_service=example_service,
|
||||||
|
example_service_upper=example_service.upper()))
|
||||||
|
|
||||||
|
external_links = service.get('external_links')
|
||||||
if external_links:
|
if external_links:
|
||||||
log.warn(
|
log.warn(
|
||||||
"Service {name} has external_links: {ext}, which are no longer "
|
"Service {name} has external_links: {ext}, which now work "
|
||||||
"supported. See https://docs.docker.com/compose/networking/ "
|
"slightly differently. In particular, two containers must be "
|
||||||
"for options on how to connect external containers to the "
|
"connected to at least one network in common in order to "
|
||||||
"compose network.".format(name=name, ext=external_links))
|
"communicate, even if explicitly linked together.\n\n"
|
||||||
|
"Either connect the external container to your app's default "
|
||||||
|
"network, or connect both the external container and your "
|
||||||
|
"service's containers to a pre-existing network. See "
|
||||||
|
"https://docs.docker.com/compose/networking/ "
|
||||||
|
"for more on how to do this."
|
||||||
|
.format(name=name, ext=external_links))
|
||||||
|
|
||||||
# net is now networks
|
# net is now network_mode
|
||||||
if 'net' in service:
|
if 'net' in service:
|
||||||
service['networks'] = [service.pop('net')]
|
network_mode = service.pop('net')
|
||||||
|
|
||||||
|
# "container:<service name>" is now "service:<service name>"
|
||||||
|
if network_mode.startswith('container:'):
|
||||||
|
name = network_mode.partition(':')[2]
|
||||||
|
if name in service_names:
|
||||||
|
network_mode = 'service:{}'.format(name)
|
||||||
|
|
||||||
|
service['network_mode'] = network_mode
|
||||||
|
|
||||||
# create build section
|
# create build section
|
||||||
if 'dockerfile' in service:
|
if 'dockerfile' in service:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user