瀏覽代碼

Added support to option mac-address

Signed-off-by: Sébastien Gruchet <[email protected]>

Updated doc

Signed-off-by: Sébastien Gruchet <[email protected]>

Fixed LINT errors

Signed-off-by: Sébastien Gruchet <[email protected]>

Changed mac-address entry order in config keys

Signed-off-by: Sébastien Gruchet <[email protected]>

Changed attributes order in docs/yml.md

Signed-off-by: Sébastien Gruchet <[email protected]>
Sébastien Gruchet 10 年之前
父節點
當前提交
b76ac6e633
共有 3 個文件被更改,包括 11 次插入1 次删除
  1. 1 0
      compose/config.py
  2. 4 1
      docs/yml.md
  3. 6 0
      tests/integration/service_test.py

+ 1 - 0
compose/config.py

@@ -23,6 +23,7 @@ DOCKER_CONFIG_KEYS = [
     'image',
     'labels',
     'links',
+    'mac_address',
     'mem_limit',
     'net',
     'log_driver',

+ 4 - 1
docs/yml.md

@@ -362,7 +362,7 @@ security_opt:
   - label:role:ROLE
 ```
 
-### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged, restart, stdin\_open, tty, cpu\_shares, cpuset, read\_only
+### working\_dir, entrypoint, user, hostname, domainname, mac\_address, mem\_limit, privileged, restart, stdin\_open, tty, cpu\_shares, cpuset, read\_only 
 
 Each of these is a single value, analogous to its
 [docker run](https://docs.docker.com/reference/run/) counterpart.
@@ -378,6 +378,8 @@ user: postgresql
 hostname: foo
 domainname: foo.com
 
+mac_address: 02:42:ac:11:65:43
+
 mem_limit: 1000000000
 privileged: true
 
@@ -386,6 +388,7 @@ restart: always
 stdin_open: true
 tty: true
 read_only: true
+
 ```
 
 ## Compose documentation

+ 6 - 0
tests/integration/service_test.py

@@ -198,6 +198,12 @@ class ServiceTest(DockerClientTestCase):
         service.start_container(container)
         self.assertEqual(set(container.get('HostConfig.SecurityOpt')), set(security_opt))
 
+    def test_create_container_with_mac_address(self):
+        service = self.create_service('db', mac_address='02:42:ac:11:65:43')
+        container = service.create_container()
+        service.start_container(container)
+        self.assertEqual(container.inspect()['Config']['MacAddress'], '02:42:ac:11:65:43')
+
     def test_create_container_with_specified_volume(self):
         host_path = '/tmp/host-path'
         container_path = '/container-path'