'Error when login to Docker container using Molecule

I have this Molecule configuration:

---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: instance1
    image: docker.io/pycontribs/centos:8
provisioner:
  name: ansible
verifier:
  name: ansible

I run molecule converge and it works fine. Now, I need to log into the instance1 container. When I run molecule login --host instance1, I get this error:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/env docker exec -e COLUMNS=108 -e LINES=41 -e TERM=bash -e TERM=xterm -ti instance1 bash'

What is happening?

Versions

docker package: 5.0.3

molecule: 3.6.1

molecule-docker: 1.1.0

NOTE

If I run the command that is getting an error:

/usr/bin/env docker exec -e COLUMNS=108 -e LINES=41 -e TERM=bash -e TERM=xterm -ti instance1 bash

in a terminal, it works fine.



Solution 1:[1]

This is a known issue with molecule not correctly expanding the shell arguments and has been fixed in this pull request: https://github.com/ansible-community/molecule/pull/3468

I've patched this pull request into my local molecule instance and can confirm it fixes this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonathan Niven