简体   繁体   中英

connecting to a docker container as a workspace

I currently use a vagrant box as my workspace for devops/cloud development.

vagrant ssh not working in MobaXterm on Windows

I saw this command for vagrant: command /drives/c/HashiCorp/Vagrant/bin/vagrant ssh-config > vagrant-ssh-config && ssh -A -F vagrant-ssh-config default

in the advanced tab of the setting.

I am wanting to use mobaxterm to connect docker container to lighten up the start and requirements for my workspace. How would I do that?

To be able to start a shell via MobaXterm on Windows:

  1. Create a new shell from MobaXterm clicking "+" tab 创建一个外壳

  2. Go to your docker install directory:

cd "C:\\Program Files\\Docker\\Docker\\Resources\\bin"

or with:

cd /drives/c/Program Files/Docker/Docker/Resources/bin

  1. Execute docker exec command with -i nteractive option only:

./docker.exe exec -i your_docker_container /bin/bash

you are now in your docker container's bash environment, you can type ls for example:

带有ls示例的Docker exec命令

If you need to connect to a remote docker instance, adapt docker command to include remote host ( -H )

Tested with Windows 10, MobaXterm v10.9, docker v18.09.2.

Note: after testing it during some time MobaXterm does not provide a good support to docker interactive console (bash support). Better use a cmd shell, powershell or similar.

@BlouBlou, thanks a lot for your answer Just adding an information that was usefull for me. When I tried to use: "./docker.exe exec -i your_docker_container /bin/bash" I connected to the terminal, but with blank screen. Tried with "-it" and I've received the message below: "the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"

I've found a simple solution in another another question that worked for me, and maybe for other users.. Just add winpty before docker.exe

cd "C:\\Program Files\\Docker\\Docker\\Resources\\bin"; winpty ./docker.exe exec -ti yourcontainer /bin/bash

worked 100%, so far.

Regards. Delocco

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM