diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c54549d..90b0a86f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ BUG FIXES: reprovision. [GH-4393] - commands/package: base package won't crash with exception [GH-4017] - commands/rsync-auto: Destroyed machines won't raise exceptions. [GH-4031] + - commands/ssh: Extra args are passed through to Docker container. [GH-4378] - communicators/ssh: Nicer error if remote unexpectedly disconects. [GH-4038] - communicators/ssh: Clean error when max sessions is hit. [GH-4044] - communicators/ssh: Fix many issues around PTY-enabled output parsing. diff --git a/plugins/providers/docker/action/prepare_ssh.rb b/plugins/providers/docker/action/prepare_ssh.rb index 344414b26..1a7298a66 100644 --- a/plugins/providers/docker/action/prepare_ssh.rb +++ b/plugins/providers/docker/action/prepare_ssh.rb @@ -19,14 +19,15 @@ module VagrantPlugins # Modify the SSH options for when we `vagrant ssh`... ssh_opts = env[:ssh_opts] || {} - # Append "-t" to force a TTY allocation - ssh_opts[:extra_args] = Array(ssh_opts[:extra_args]) - ssh_opts[:extra_args] << "-t" + # Build the command we'll execute within the host machine + ssh_command = env[:machine].communicate.container_ssh_command + if !Array(ssh_opts[:extra_args]).empty? + ssh_command << " #{Array(ssh_opts[:extra_args]).join(" ")}" + end - # Append our real SSH command. If we have a host VM we know - # we're using our special communicator, so we can call helpers there - ssh_opts[:extra_args] << - env[:machine].communicate.container_ssh_command + # Append "-t" to force a TTY allocation + ssh_opts[:extra_args] = ["-t"] + ssh_opts[:extra_args] << ssh_command # Set the opts env[:ssh_opts] = ssh_opts