-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
override_command
command to platforms definition (#1771)
Closes #1763. This adds a `override_command` key to the platforms definition. It defaults to true. A user who wants to override the `CMD` directive from their `Dockerfile.j2` can specify `override_command: False` to have it honoured. This allows 3 use cases to be covered: * Getting the zero configuration default of `bash -c ...` * Overriding the `CMD` directive from the `command` key * Overriding the `CMD` directive from the `Dockerfile.j2` and setting `override_command: false` See also: * #1615 * #1614 * #1441 Signed-off-by: Luke Murphy <[email protected]>
- Loading branch information
1 parent
d7e209f
commit 414489e
Showing
7 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ class Docker(base.Base): | |
username: $USERNAME | ||
password: $PASSWORD | ||
email: [email protected] | ||
override_command: True|False | ||
command: sleep infinity | ||
privileged: True|False | ||
security_opts: | ||
|
@@ -88,6 +89,12 @@ class Docker(base.Base): | |
buildargs: | ||
http_proxy: http://proxy.example.com:8080/ | ||
If specifying the `CMD`_ directive in your ``Dockerfile.j2`` or consuming a | ||
built image which declares a ``CMD`` directive, then you must set | ||
``override_command: False``. Otherwise, Molecule takes care to honour the | ||
value of the ``command`` key or uses the default of ``bash -c "while true; | ||
do sleep 10000; done"`` to run the container until it is provisioned. | ||
When attempting to utilize a container image with `systemd`_ as your init | ||
system inside the container to simulate a real machine, make sure to set | ||
the ``privileged``, ``volume_mounts``, ``command``, and ``environment`` | ||
|
@@ -133,6 +140,7 @@ class Docker(base.Base): | |
.. _`Docker`: https://www.docker.com | ||
.. _`systemd`: https://www.freedesktop.org/wiki/Software/systemd/ | ||
.. _`CMD`: https://docs.docker.com/engine/reference/builder/#cmd | ||
""" # noqa | ||
|
||
def __init__(self, config): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ def _model_platforms_docker_section_data(): | |
'email': '[email protected]', | ||
}, | ||
}, | ||
'override_command': | ||
False, | ||
'command': | ||
'sleep infinity', | ||
'privileged': | ||
|
@@ -126,6 +128,7 @@ def _model_platforms_docker_errors_section_data(): | |
'email': int(), | ||
}, | ||
}, | ||
'override_command': int(), | ||
'command': int(), | ||
'privileged': str(), | ||
'security_opts': [ | ||
|
@@ -189,6 +192,7 @@ def test_platforms_docker_has_errors(_config): | |
0: ['must be of string type'] | ||
}], | ||
'privileged': ['must be of boolean type'], | ||
'override_command': ['must be of boolean type'], | ||
'command': ['must be of string type'], | ||
'registry': [{ | ||
'url': ['must be of string type'], | ||
|