Kitchen-docker Using non-default ssh port

I have built an docker image with non-default ssh port. But when I try to use it for test kitchen, kitchen conv is not able to enter into container because of wrong ssh port:

[kitchen::driver::docker command] BEGIN (sudo -E docker -H unix:///var/run/docker.sock port 780f25214dbd47412b90467ae3dfcbafca0fcb2fa99ba3f5282ddc5b245a1b89 22/tcp)

My .kitchen.yml is as following:

  name: docker

  name: chef_solo

  - name: docker-rhel-6.8
      name: docker
      image: rhel_test
      platform: rhel
      port: 2222

  name: ssh
  ssh_port: 2222

  - name: default
      name: docker
        - 80
      - recipe[test::default]

Any leads what can be done to use non-default ssh port using kitchen-docker? I have tried both options, port and ssh_port , but no luck.

Thanks in advance!

Kitchen-docker uses Docker’s randomized port allocations for the actual transport port (i.e. we read out of the container data to know what port on the hypervisor to use). As for making sshd inside the container listen on something other than 22, that’s not supported at this time and I have trouble imagining why it would need to be.

1 Like

Thanks for your reply @coderanger. I needed to test some compliance tests for ssh service. As we use kitchen-docker for testing, it seemed worth a try.

The internal ssh service is bound to 2222 i dont think you need to care
what the port is on the docker host… this can be random. Just run your
compliance from inside the container.