Improving Docker based Installation (#1194)

To be able to use 'vagrant ssh' from within the docker container, it is 
necessary to run within the host network context.

Include a helper alias suggestion and a note about a current issue in 
passing arguments to vagrant options which impacts the 'vagrant ssh -c 
...' syntax with an alternative.
This commit is contained in:
pgillich 2021-01-05 11:35:20 +01:00 committed by GitHub
parent 5471caabe5
commit 441bcc24bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -66,6 +66,8 @@ RUN for dir in boxes data tmp; \
FROM base as final FROM base as final
ENV VAGRANT_DEFAULT_PROVIDER=libvirt
COPY --from=build /vagrant /vagrant COPY --from=build /vagrant /vagrant
COPY entrypoint.sh /usr/local/bin/ COPY entrypoint.sh /usr/local/bin/

View File

@ -111,6 +111,12 @@ To get the image:
docker pull vagrantlibvirt/vagrant-libvirt:latest docker pull vagrantlibvirt/vagrant-libvirt:latest
``` ```
Preparing the docker run, only once:
```bash
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
```
Running the image: Running the image:
```bash ```bash
docker run -it --rm \ docker run -it --rm \
@ -119,10 +125,35 @@ docker run -it --rm \
-v ~/.vagrant.d:/.vagrant.d \ -v ~/.vagrant.d:/.vagrant.d \
-v $(pwd):$(pwd) \ -v $(pwd):$(pwd) \
-w $(pwd) \ -w $(pwd) \
--network host \
vagrantlibvirt/vagrant-libvirt:latest \ vagrantlibvirt/vagrant-libvirt:latest \
vagrant status vagrant status
``` ```
It's possible to define an alias in `~/.bashrc`, for example:
```bash
alias vagrant='
mkdir -p ~/.vagrant.d/{boxes,data,tmp}; \
docker run -it --rm \
-e LIBVIRT_DEFAULT_URI \
-v /var/run/libvirt/:/var/run/libvirt/ \
-v ~/.vagrant.d:/.vagrant.d \
-v $(pwd):$(pwd) \
-w $(pwd) \
--network host \
vagrantlibvirt/vagrant-libvirt:latest \
vagrant'
```
Known issue of Docker based Installation: SSH command option cannot be used, so below command:
```bash
vagrant ssh master -c 'ls -la'
```
should be call below way:
```bash
vagrant ssh master -- 'ls -la'
```
Note that if you are connecting to a remote system libvirt, you may omit the Note that if you are connecting to a remote system libvirt, you may omit the
`-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local `-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local
vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you