I installed Docker Desktop for Windows on Windows 10 with https://docs.docker.com/docker-for-windows/install/#install-docker-for-windows. It not uses VirtualBox and default VM to host docker.
I am able to run containers but how I connect to a docker with ssh?
docker-machine ls does not show my docker host.
Tried to connect to docker#10.0.75.1 but it requires password. And tcuser that used for boot2docker VM not matching:
ssh docker#10.0.75.1 Could not create directory '/home/stan/.ssh'. The
authenticity of host '10.0.75.1 (10.0.75.1)' can't be established. RSA
key fingerprint is .... Are you sure you want to continue connecting
(yes/no)? yes Failed to add the host to the list of known hosts
(/home/stan/.ssh/known_hosts). docker#10.0.75.1's password: Write
failed: Connection reset by peer
Run this:
docker run -it --rm --privileged --pid=host justincormack/nsenter1
Just run this from your CLI and it'll drop you in a container with
full permissions on the Moby VM. Only works for Moby Linux VM (doesn't
work for Windows Containers). Note this also works on Docker for Mac.
Reference:
https://www.bretfisher.com/getting-a-shell-in-the-docker-for-windows-vm/
As far as I know you can't connect to the docker VM using SSH and you cannot connect to the console/terminal using Hyper-V Manager either. https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/17
Related
I am a newbie with docker. I need to use it at windows 7*64 , via docker toolbox. I need to make a connection to server below:
Run the server:
docker run -p 4444:4444 mycontainerWithServer
After this i open new docker toolbox window and try to connect to localhost:4444. I get ConnectionRefused error.
Because you are using the Docker toolbox you don't access your containers on localhost. The toolbox uses 192.168.99.100 by default because it is running on a Linux VM. Try replacing localhost with the VM IP.
I have installed a repo from docker and ran it using the following command,
docker run -d --name searx -p $PORT:8888 wonderfall/searx
The container was also sucessfully created but while accessing it in my browser i get the following error,
dail tcp[::1]:8888: connectex: No connection could be made because the target machine actively refused it.
Does anyone know why this error occurs? I use a windows10 system.
Just installed docker toolbox
That means you cannot use localhost directly without declaring in Virtual Box a port-forwarding rule.
First, test your service using the IP of your VM (see docker-machine ip default output)
http://<ip>:8888
Then, declare a port-forward rule:
either directly in your VirtualBox graphical interface: see "How do I configure docker compose to expose ports correctly?"
or with VBoxManage controlvm commands: see "Not able to access tomcat application on Docker VM with host(windows) IP while using docker toolbox"
Im running Docker Desktop for Windows (hyper V) and I need to access docker daemon from the container via tcp. It is possible to connect to it from the host like:
curl -v 127.0.0.1:2375/info but not possible to access it from a container using my host IP address. Maybe someone knows how to do that or at least how to ssh to that docker vm, for example it is possible to ssh in to it on mac by executing:
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
I've figured how to do that using socat tool which takes docket.socket and proxy TCP calls to it.
So I've launched container with a socat which mount docker.sock since it is available inside of a VM and expose 2375 port:
docker run -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock codenvy/socat -d -d TCP-L:2375,fork UNIX:/var/run/docker.sock
With that now, I'm able to access docker daemon API through socat container.
I´ve been looking in google but i cannot find any answer.
It is possible connect to a virtualbox docker container that I just start up. I have the IP of the virtual machine, but if I try to connect by SSH of course ask me for a password.
Regards.
see
https://github.com/BITPlan/docker-stackoverflowanswers/tree/master/33232371
to repeat steps.
On my Mac OS X machine
docker-machine env default
shows
export DOCKER_HOST="tcp://192.168.99.100:2376"
So i added an entry
192.168.99.100 docker
to my /etc/hosts
so that ping docker works.
As a Dockerfile i am using:
# Ubuntu image
FROM ubuntu:14.04
which I am building with
docker build -t bitplan/sshtest:0.0.1 .
and testing with
docker run -it bitplan/sshtest:0.0.1 /bin/bash
Now ssh docker will react with
The authenticity of host 'docker (192.168.99.100)' can't be established.
ECDSA key fingerprint is SHA256:osRuE6B8bCIGiL18uBBrtySH5+iGPkiHHiq5PZNfDmc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'docker,192.168.99.100' (ECDSA) to the list of known hosts.
wf#docker's password:
But here you are connecting to the docker machine not your image!
The ssh port is at port 22. You need to redirect it to another port and configure your image to support ssh to root or a valid user.
See e.g. https://docs.docker.com/examples/running_ssh_service/
Are you trying to connect to a running container or trying to connect to the virtualbox image running the docker daemon?
If the first, you cannot just SSH into a running container unless that container is running an ssh daemon. The easiest way to get a shell into a running container is with docker exec -ti <container name/id> /bin/sh. Do a docker ps to see running containers.
If the second, if your host was created with docker-machine then you can ssh into it with docker-machine ssh <machine name>. You can see all of you're running machines with docker-machine ls.
If this doesn't help can you clarify your question a little and provide details around how your creating your image and starting the container.
You can use ssh keys to access passwordless.
Here's some intro
https://wiki.archlinux.org/index.php/SSH_keys
I've noticed that boot2docker runs docker on a VM as a deamon on port 2375.
Then I use local Mac OS X 'docker' command and it executes all calls on VM.
These are the commands I use:
boot2docker start
export DOCKER_HOST=tcp://:2375
And then 'docker images' (for example) is running on VM.
How can I do the same with a physical machine rather then VM?
boot2docker is meant to be for dev purpose. It will spawn a VM. For bare metal, simply install docker on the host and start the docker daemon with docker -d -H tcp://0.0.0.0:4243.
WARNING: This is very dangerous. Anyone will have root access to your host. In order to secure this, you should change 0.0.0.0 to 127.0.0.1 and either use a SSH tunnel or a nginx/apache frontend with authentification.
On you mac, then just export DOCKER_HOST=tcp://<host ip>:4243