mirror of https://github.com/docker/docs.git
Merge pull request #1445 from aanand/replace-sleep-with-top
Use 'top' instead of 'sleep' as a dummy command
This commit is contained in:
commit
c0f65a9f4c
|
@ -1,6 +1,6 @@
|
||||||
simple:
|
simple:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
another:
|
another:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
FROM busybox
|
FROM busybox
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
CMD sleep 3000
|
CMD top
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
service:
|
service:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: sleep 5
|
command: top
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
foo: bar
|
foo: bar
|
||||||
|
|
|
@ -2,7 +2,7 @@ myweb:
|
||||||
extends:
|
extends:
|
||||||
file: common.yml
|
file: common.yml
|
||||||
service: web
|
service: web
|
||||||
command: sleep 300
|
command: top
|
||||||
links:
|
links:
|
||||||
- "mydb:db"
|
- "mydb:db"
|
||||||
environment:
|
environment:
|
||||||
|
@ -13,4 +13,4 @@ myweb:
|
||||||
BAZ: "2"
|
BAZ: "2"
|
||||||
mydb:
|
mydb:
|
||||||
image: busybox
|
image: busybox
|
||||||
command: sleep 300
|
command: top
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
db:
|
db:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
web:
|
web:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
links:
|
links:
|
||||||
- db:db
|
- db:db
|
||||||
console:
|
console:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
definedinyamlnotyml:
|
definedinyamlnotyml:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
|
@ -1,3 +1,3 @@
|
||||||
yetanother:
|
yetanother:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
simple:
|
simple:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
another:
|
another:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
simple:
|
simple:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
ports:
|
ports:
|
||||||
- '3000'
|
- '3000'
|
||||||
- '49152:3001'
|
- '49152:3001'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
simple:
|
simple:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
another:
|
another:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: /bin/sleep 300
|
command: top
|
||||||
|
|
|
@ -78,12 +78,12 @@ class ProjectTest(DockerClientTestCase):
|
||||||
service_dicts=config.from_dictionary({
|
service_dicts=config.from_dictionary({
|
||||||
'net': {
|
'net': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"]
|
'command': ["top"]
|
||||||
},
|
},
|
||||||
'web': {
|
'web': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'net': 'container:net',
|
'net': 'container:net',
|
||||||
'command': ["/bin/sleep", "300"]
|
'command': ["top"]
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
client=self.client,
|
client=self.client,
|
||||||
|
@ -103,7 +103,7 @@ class ProjectTest(DockerClientTestCase):
|
||||||
self.client,
|
self.client,
|
||||||
image='busybox:latest',
|
image='busybox:latest',
|
||||||
name='composetest_net_container',
|
name='composetest_net_container',
|
||||||
command='/bin/sleep 300'
|
command='top'
|
||||||
)
|
)
|
||||||
net_container.start()
|
net_container.start()
|
||||||
|
|
||||||
|
@ -288,20 +288,20 @@ class ProjectTest(DockerClientTestCase):
|
||||||
service_dicts=config.from_dictionary({
|
service_dicts=config.from_dictionary({
|
||||||
'console': {
|
'console': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
},
|
},
|
||||||
'data': {
|
'data': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"]
|
'command': ["top"]
|
||||||
},
|
},
|
||||||
'db': {
|
'db': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
'volumes_from': ['data'],
|
'volumes_from': ['data'],
|
||||||
},
|
},
|
||||||
'web': {
|
'web': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
'links': ['db'],
|
'links': ['db'],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -326,20 +326,20 @@ class ProjectTest(DockerClientTestCase):
|
||||||
service_dicts=config.from_dictionary({
|
service_dicts=config.from_dictionary({
|
||||||
'console': {
|
'console': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
},
|
},
|
||||||
'data': {
|
'data': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"]
|
'command': ["top"]
|
||||||
},
|
},
|
||||||
'db': {
|
'db': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
'volumes_from': ['data'],
|
'volumes_from': ['data'],
|
||||||
},
|
},
|
||||||
'web': {
|
'web': {
|
||||||
'image': 'busybox:latest',
|
'image': 'busybox:latest',
|
||||||
'command': ["/bin/sleep", "300"],
|
'command': ["top"],
|
||||||
'links': ['db'],
|
'links': ['db'],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -236,7 +236,7 @@ class ServiceTest(DockerClientTestCase):
|
||||||
def test_create_container_with_volumes_from(self):
|
def test_create_container_with_volumes_from(self):
|
||||||
volume_service = self.create_service('data')
|
volume_service = self.create_service('data')
|
||||||
volume_container_1 = volume_service.create_container()
|
volume_container_1 = volume_service.create_container()
|
||||||
volume_container_2 = Container.create(self.client, image='busybox:latest', command=["/bin/sleep", "300"])
|
volume_container_2 = Container.create(self.client, image='busybox:latest', command=["top"])
|
||||||
host_service = self.create_service('host', volumes_from=[volume_service, volume_container_2])
|
host_service = self.create_service('host', volumes_from=[volume_service, volume_container_2])
|
||||||
host_container = host_service.create_container()
|
host_container = host_service.create_container()
|
||||||
host_service.start_container(host_container)
|
host_service.start_container(host_container)
|
||||||
|
@ -250,12 +250,12 @@ class ServiceTest(DockerClientTestCase):
|
||||||
'db',
|
'db',
|
||||||
environment={'FOO': '1'},
|
environment={'FOO': '1'},
|
||||||
volumes=['/etc'],
|
volumes=['/etc'],
|
||||||
entrypoint=['sleep'],
|
entrypoint=['top'],
|
||||||
command=['300']
|
command=['-d', '1']
|
||||||
)
|
)
|
||||||
old_container = service.create_container()
|
old_container = service.create_container()
|
||||||
self.assertEqual(old_container.get('Config.Entrypoint'), ['sleep'])
|
self.assertEqual(old_container.get('Config.Entrypoint'), ['top'])
|
||||||
self.assertEqual(old_container.get('Config.Cmd'), ['300'])
|
self.assertEqual(old_container.get('Config.Cmd'), ['-d', '1'])
|
||||||
self.assertIn('FOO=1', old_container.get('Config.Env'))
|
self.assertIn('FOO=1', old_container.get('Config.Env'))
|
||||||
self.assertEqual(old_container.name, 'composetest_db_1')
|
self.assertEqual(old_container.name, 'composetest_db_1')
|
||||||
service.start_container(old_container)
|
service.start_container(old_container)
|
||||||
|
@ -267,8 +267,8 @@ class ServiceTest(DockerClientTestCase):
|
||||||
service.options['environment']['FOO'] = '2'
|
service.options['environment']['FOO'] = '2'
|
||||||
new_container = service.converge()[0]
|
new_container = service.converge()[0]
|
||||||
|
|
||||||
self.assertEqual(new_container.get('Config.Entrypoint'), ['sleep'])
|
self.assertEqual(new_container.get('Config.Entrypoint'), ['top'])
|
||||||
self.assertEqual(new_container.get('Config.Cmd'), ['300'])
|
self.assertEqual(new_container.get('Config.Cmd'), ['-d', '1'])
|
||||||
self.assertIn('FOO=2', new_container.get('Config.Env'))
|
self.assertIn('FOO=2', new_container.get('Config.Env'))
|
||||||
self.assertEqual(new_container.name, 'composetest_db_1')
|
self.assertEqual(new_container.name, 'composetest_db_1')
|
||||||
self.assertEqual(new_container.get('Volumes')['/etc'], volume_path)
|
self.assertEqual(new_container.get('Volumes')['/etc'], volume_path)
|
||||||
|
@ -287,8 +287,8 @@ class ServiceTest(DockerClientTestCase):
|
||||||
'db',
|
'db',
|
||||||
environment={'FOO': '1'},
|
environment={'FOO': '1'},
|
||||||
volumes=['/var/db'],
|
volumes=['/var/db'],
|
||||||
entrypoint=['sleep'],
|
entrypoint=['top'],
|
||||||
command=['300']
|
command=['-d', '1']
|
||||||
)
|
)
|
||||||
service.create_container()
|
service.create_container()
|
||||||
self.assertEqual(len(service.containers(stopped=True)), 1)
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
||||||
|
|
|
@ -167,7 +167,7 @@ class ServiceStateTest(DockerClientTestCase):
|
||||||
self.assertEqual(('noop', [container]), web.convergence_plan(smart_recreate=True))
|
self.assertEqual(('noop', [container]), web.convergence_plan(smart_recreate=True))
|
||||||
|
|
||||||
def test_trigger_start(self):
|
def test_trigger_start(self):
|
||||||
options = dict(command=["/bin/sleep", "300"])
|
options = dict(command=["top"])
|
||||||
|
|
||||||
web = self.create_service('web', **options)
|
web = self.create_service('web', **options)
|
||||||
web.scale(2)
|
web.scale(2)
|
||||||
|
@ -185,10 +185,10 @@ class ServiceStateTest(DockerClientTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_trigger_recreate_with_config_change(self):
|
def test_trigger_recreate_with_config_change(self):
|
||||||
web = self.create_service('web', command=["/bin/sleep", "300"])
|
web = self.create_service('web', command=["top"])
|
||||||
container = web.create_container()
|
container = web.create_container()
|
||||||
|
|
||||||
web = self.create_service('web', command=["/bin/sleep", "400"])
|
web = self.create_service('web', command=["top", "-d", "1"])
|
||||||
self.assertEqual(('recreate', [container]), web.convergence_plan(smart_recreate=True))
|
self.assertEqual(('recreate', [container]), web.convergence_plan(smart_recreate=True))
|
||||||
|
|
||||||
def test_trigger_recreate_with_image_change(self):
|
def test_trigger_recreate_with_image_change(self):
|
||||||
|
@ -254,10 +254,10 @@ class ConfigHashTest(DockerClientTestCase):
|
||||||
self.assertIn('foo', container.labels)
|
self.assertIn('foo', container.labels)
|
||||||
|
|
||||||
def test_config_hash_sticks_around(self):
|
def test_config_hash_sticks_around(self):
|
||||||
web = self.create_service('web', command=["/bin/sleep", "300"])
|
web = self.create_service('web', command=["top"])
|
||||||
container = web.converge()[0]
|
container = web.converge()[0]
|
||||||
self.assertIn(LABEL_CONFIG_HASH, container.labels)
|
self.assertIn(LABEL_CONFIG_HASH, container.labels)
|
||||||
|
|
||||||
web = self.create_service('web', command=["/bin/sleep", "400"])
|
web = self.create_service('web', command=["top", "-d", "1"])
|
||||||
container = web.converge()[0]
|
container = web.converge()[0]
|
||||||
self.assertIn(LABEL_CONFIG_HASH, container.labels)
|
self.assertIn(LABEL_CONFIG_HASH, container.labels)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DockerClientTestCase(unittest.TestCase):
|
||||||
kwargs['image'] = 'busybox:latest'
|
kwargs['image'] = 'busybox:latest'
|
||||||
|
|
||||||
if 'command' not in kwargs:
|
if 'command' not in kwargs:
|
||||||
kwargs['command'] = ["/bin/sleep", "300"]
|
kwargs['command'] = ["top"]
|
||||||
|
|
||||||
return Service(
|
return Service(
|
||||||
project='composetest',
|
project='composetest',
|
||||||
|
|
|
@ -348,12 +348,12 @@ class ExtendsTest(unittest.TestCase):
|
||||||
{
|
{
|
||||||
'name': 'mydb',
|
'name': 'mydb',
|
||||||
'image': 'busybox',
|
'image': 'busybox',
|
||||||
'command': 'sleep 300',
|
'command': 'top',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'myweb',
|
'name': 'myweb',
|
||||||
'image': 'busybox',
|
'image': 'busybox',
|
||||||
'command': 'sleep 300',
|
'command': 'top',
|
||||||
'links': ['mydb:db'],
|
'links': ['mydb:db'],
|
||||||
'environment': {
|
'environment': {
|
||||||
"FOO": "1",
|
"FOO": "1",
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ContainerTest(unittest.TestCase):
|
||||||
self.container_dict = {
|
self.container_dict = {
|
||||||
"Id": "abc",
|
"Id": "abc",
|
||||||
"Image": "busybox:latest",
|
"Image": "busybox:latest",
|
||||||
"Command": "sleep 300",
|
"Command": "top",
|
||||||
"Created": 1387384730,
|
"Created": 1387384730,
|
||||||
"Status": "Up 8 seconds",
|
"Status": "Up 8 seconds",
|
||||||
"Ports": None,
|
"Ports": None,
|
||||||
|
|
Loading…
Reference in New Issue