From docker only output vagrant to stdout (#1464)

When running the docker container, only output what is returned by
vagrant to stdout, and redirect everything else to stderr to facilitate
anything parsing stdout.

Fixes: #1463
This commit is contained in:
Darragh Bailey
2022-03-12 17:41:27 +00:00
committed by GitHub
parent 1b8a70163b
commit 0f4a97e1dd
2 changed files with 11 additions and 5 deletions

View File

@@ -49,8 +49,8 @@ can help a lot :-)
* [USB Device Passthrough](#usb-device-passthrough) * [USB Device Passthrough](#usb-device-passthrough)
* [USB Redirector Devices](#usb-redirector-devices) * [USB Redirector Devices](#usb-redirector-devices)
* [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices) * [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
* [Random number generator passthrough](#random-number-generator-passthrough)
* [Serial Console Devices](#serial-console-devices) * [Serial Console Devices](#serial-console-devices)
* [Random number generator passthrough](#random-number-generator-passthrough)
* [Watchdog device](#watchdog-device) * [Watchdog device](#watchdog-device)
* [Smartcard device](#smartcard-device) * [Smartcard device](#smartcard-device)
* [Hypervisor Features](#hypervisor-features) * [Hypervisor Features](#hypervisor-features)
@@ -141,7 +141,7 @@ docker pull vagrantlibvirt/vagrant-libvirt:edge
Running the image: Running the image:
```bash ```bash
docker run -it --rm \ docker run -i --rm \
-e LIBVIRT_DEFAULT_URI \ -e LIBVIRT_DEFAULT_URI \
-v /var/run/libvirt/:/var/run/libvirt/ \ -v /var/run/libvirt/:/var/run/libvirt/ \
-v ~/.vagrant.d:/.vagrant.d \ -v ~/.vagrant.d:/.vagrant.d \
@@ -155,7 +155,7 @@ docker run -it --rm \
It's possible to define a function in `~/.bashrc`, for example: It's possible to define a function in `~/.bashrc`, for example:
```bash ```bash
vagrant(){ vagrant(){
docker run -it --rm \ docker run -i --rm \
-e LIBVIRT_DEFAULT_URI \ -e LIBVIRT_DEFAULT_URI \
-v /var/run/libvirt/:/var/run/libvirt/ \ -v /var/run/libvirt/:/var/run/libvirt/ \
-v ~/.vagrant.d:/.vagrant.d \ -v ~/.vagrant.d:/.vagrant.d \

View File

@@ -2,6 +2,12 @@
set -u -o pipefail set -u -o pipefail
# duplicate stdout as fd 3
exec 3>&1
# redirect stdout to stderr by default
exec 1>&2
vdir="/.vagrant.d" vdir="/.vagrant.d"
if [[ ! -d ${vdir} ]] if [[ ! -d ${vdir} ]]
@@ -145,7 +151,7 @@ fi
if [[ $# -eq 0 ]] if [[ $# -eq 0 ]]
then then
# if no command provided # if no command provided
exec gosu ${USER} vagrant help exec gosu ${USER} vagrant help >&3
fi fi
exec gosu ${USER} "$@" exec gosu ${USER} "$@" >&3