Keep files in `/bin` & change the log-in user
Closed this issue · 8 comments
Hi @ailispaw , I have two questions.
- I want to save a file in
/bin
. However, the file will be removed aftervagrant halt && vagrant up
orvagrant reload
. Are there any ways to keep files in/bin
? - What's the easiest way to change the log-in user?
Hi @ixkaito,
- You can use
/opt/bin
instead.
/opt, /home and /etc are persistent. - You can override the user by setting
config.ssh.username
and so on.
Cf.) https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html
$ vagrant ssh
Welcome to DockerRoot version 1.2.5, Docker version 1.9.1, build a34a1d5
[docker@docker-root ~]$ sudo adduser -h /home/ailispaw -s /bin/bash -G docker ailispaw
[docker@docker-root ~]$ sudo sudo cp -r ~/.ssh/ /home/ailispaw
[docker@docker-root ~]$ sudo chown -R ailispaw /home/ailispaw/.ssh
[docker@docker-root ~]$ exit
Add config.ssh.username = "ailispaw"
into Vagrantfile
$ vagrant ssh
Welcome to DockerRoot version 1.2.5, Docker version 1.9.1, build a34a1d5
[ailispaw@docker-root ~]$
Thanks!
/opt/bin
works well after vagrant ssh
. However, if I don't log in or execute my command in the provisioning, it will be not found.
$ vagrant ssh -- mycommand
bash: mycommand: command not found
config.ssh.username
works after the first vagrant up
. If I want to use another user than docker
at the first vagrant up
, I have to build my own box, haven't I?
Try vagrant ssh -c 'yourcommand'
.
If I want to use another user than docker at the first vagrant up, I have to build my own box, haven't I?
Yes.
Just curious, what do you need an another user for?
Oh, you are right. > bash: mycommand: command not found
I will figure this out.
I got it.
/opt/bin
is set into PATH
when a user is in login shell but just shell.
The ailispaw/docker-root
box has config.ssh.shell = "bash"
, not "bash -l".
You have some options for now.
- Add
config.ssh.shell = "bash -l"
into your Vagrantfile andvagrant ssh -c 'yourcommand'
. vagrant ssh -c 'bash -l -c "yourcommand"'
vagrant ssh -c '/opt/bin/yourcommand'
I will consider how I can fix this issue in the box.
Thanks.
Fix in ailispaw/docker-root
box v1.2.6.
b9eb1ab
ailispaw/docker-root-packer@b63bc13
Just curious, what do you need an another user for?
Never mind. This is not important. I just wanted to change it to my project name if I could do it easily.
v1.2.6 works perfectly! Many thanks. I will release a major update of my project 'Wocker' using DockerRoot in a few days:)