Reputation: 27
~/.ssh/my_id_rsa
in a VM created by docker-machine create
gets disappeared whenever I restart it. I've read documents on docs.docker.com, but I couldn't find information about this issue.
My host machine is Mac (El Capitan), and the version of docker-machine is as follows:
$ docker-machine version
docker-machine version 0.6.0, build e27fb87
I've created my VM with following options:
$ docker-machine create --driver virtualbox dev
Is there any advice on how to fix this issue? Where should I look into?
(host) $ docker-machine create --driver virtualbox dev
(host) $ docker-machine ssh dev
(dev) $ ssh-keygen
...
(dev) $ ls ~/.ssh
authorized_keys authorized_keys2 id_rsa id_rsa.pub
(dev) $ logout
(host) $ docker-machine restart dev
(host) $ docker-machine ssh dev
(dev) $ ls ~/.ssh
authorized_keys authorized_keys2
Where's "id_rsa" and "id_rsa.pub"?
Upvotes: 1
Views: 1384
Reputation: 1326716
Usually, I don't specify anything regarding ssh keys: docker-machine
creates a passphrase-less ssh key in ~/.docker/machine/machines/<amachine>/
If you want to specify your own, see this example from the docker-machine
documentation:
$ docker-machine create \
--driver generic \
--generic-ip-address=203.0.113.81 \
--generic-ssh-key=~/.ssh/id_rsa \
vm
The OP adds:
(dev) $ logout
(host) $ docker-machine restart dev
(host) $ docker-machine ssh dev
That is creating ssh key within the virtual machine itself: the TinyCore-based boot2docker only persists what is in /var/lib/boot2docker, nothing else.
It does mount /Users
, but other than that, anything else (including /home/docker
, the ~
in ~/.ssh
)is reset to the boot2docker.iso
original content at the next restart.
See "boot2docker: Persist data"
For those ssh keys to persists across session, you would need to either:
/var/lib/boot2docker
Upvotes: 2