diff --git a/molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/Dockerfile.j2 b/molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/Dockerfile.j2 index c727a0564b..88feb252c3 100644 --- a/molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/Dockerfile.j2 +++ b/molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/Dockerfile.j2 @@ -14,3 +14,5 @@ RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y pyth elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi {%- endraw %} + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/molecule/model/schema_v2.py b/molecule/model/schema_v2.py index db7498e6aa..bc66682286 100644 --- a/molecule/model/schema_v2.py +++ b/molecule/model/schema_v2.py @@ -638,6 +638,7 @@ def pre_validate_base_schema(env, keep_string): }, 'command': { 'type': 'string', + 'nullable': True, }, 'privileged': { 'type': 'boolean', diff --git a/molecule/provisioner/ansible/playbooks/docker/create.yml b/molecule/provisioner/ansible/playbooks/docker/create.yml index fa88eca5dd..343c22c40c 100644 --- a/molecule/provisioner/ansible/playbooks/docker/create.yml +++ b/molecule/provisioner/ansible/playbooks/docker/create.yml @@ -63,7 +63,7 @@ state: started recreate: false log_driver: json-file - command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" + command: "{{ item.command | default(omit) }}" privileged: "{{ item.privileged | default(omit) }}" security_opts: "{{ item.security_opts | default(omit) }}" volumes: "{{ item.volumes | default(omit) }}" diff --git a/test/resources/playbooks/docker/Dockerfile.j2 b/test/resources/playbooks/docker/Dockerfile.j2 index 0a605536a2..7605e1bcb3 100644 --- a/test/resources/playbooks/docker/Dockerfile.j2 +++ b/test/resources/playbooks/docker/Dockerfile.j2 @@ -12,3 +12,5 @@ RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y pyth elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi + +CMD ["sh", "-c", "while true; do sleep 10000; done"]