1DISTROBOX-EXPORT(1) User Manual DISTROBOX-EXPORT(1)
2
3
4
6 distrobox-export
7
9 Application and service exporting
10
11 distrobox-export takes care of exporting an app a binary or a service
12 from the container to the host.
13
14 The exported app will be easily available in your normal launcher and
15 it will automatically be launched from the container it is exported
16 from.
17
19 distrobox-export
20
21 --app/-a: name of the application to export
22 --bin/-b: absolute path of the binary to export
23 --service/-s: name of the service to export
24 --delete/-d: delete exported application or service
25 --export-label/-el: label to add to exported application name.
26 Defaults to (on \$container_name)
27 --export-path/-ep: path where to export the binary
28 --extra-flags/-ef: extra flags to add to the command
29 --sudo/-S: specify if the exported item should be run as sudo
30 --help/-h: show this message
31 --verbose/-v: show more verbosity
32 --version/-V: show version
33
34 You may want to install graphical applications or user services in your
35 distrobox. Using distrobox-export from inside the container will let
36 you use them from the host itself.
37
39 distrobox-export --app mpv [--extra-flags "flags"] [--delete] [--sudo]
40 distrobox-export --service syncthing [--extra-flags "flags"] [--delete] [--sudo]
41 distrobox-export --bin /path/to/bin --export-path ~/.local/bin [--extra-flags "flags"] [--delete] [--sudo]
42
43 App export example
44
45 distrobox-export --app abiword
46
47 This tool will simply copy the original .desktop files along with need‐
48 ed icons, add the prefix /usr/local/bin/distrobox-enter -n dis‐
49 trobox_name -e ... to the commands to run, and save them in your home
50 to be used directly from the host as a normal app.
51
52 Service export example
53
54 distrobox-export --service syncthing --extra-flags "--allow-newer-config"
55 distrobox-export --service nginx --sudo
56
57 For services, it will similarly export the systemd unit inside the con‐
58 tainer to a systemctl --user service, prefixing the various ExecStart
59 ExecStartPre ExecStartPost ExecReload ExecStop ExecStopPost with the
60 distrobox-enter command prefix.
61
62 The exported services will be available in the host’s user’s systemd
63 session, so
64
65 systemctl --user status exported_service_name
66
67 will show the status of the service exported.
68
69 Binary export example
70
71 distrobox-export --bin /usr/bin/code --extra-flags "--foreground" --export-path $HOME/.local/bin
72
73 In the case of exporting binaries, you will have to specify where to
74 export it (--export-path) and the tool will create a little wrapper
75 script that will distrobox-enter -e from the host, the desired binary.
76 This can be handy with the use of direnv to have different versions of
77 the same binary based on your env or project.
78
79 The exported binaries will be exported in the “–export-path” of choice
80 as a wrapper script that acts naturally both on the host and in the
81 container. Note that “–export-path” is NOT OPTIONAL, you have to ex‐
82 plicitly set it.
83
84 Additional flags
85
86 You can specify additional flags to add to the command, for example if
87 you want to export an electron app, you could add the “–foreground”
88 flag to the command:
89
90 distrobox-export --app atom --extra-flags "--foreground"
91 distrobox-export --bin /usr/bin/vim --export-path ~/.local/bin --extra-flags "-p"
92 distrobox-export --service syncthing --extra-flags "-allow-newer-config"
93
94 This works for services, binaries, and apps. Extra flags are only used
95 then the exported app, binary, or service is used from the host, using
96 them inside the container will not include them.
97
98 Unexport
99
100 The option “–delete” will un-export an app, binary, or service.
101
102 distrobox-export --app atom --delete
103 distrobox-export --bin /usr/bin/vim --export-path ~/.local/bin --delete
104 distrobox-export --service syncthing --delete
105 distrobox-export --service nginx --delete
106
107 Run as root in the container
108
109 The option “–sudo” will launch the exported item as root inside the
110 distrobox.
111
112 Exporting apps from rootful containers
113
114 It is worth noting that, when exporting any item - which includes
115 graphical apps - from rootful containers (created with distrobox create
116 --root), root privileges will be needed every time the item is launched
117 (in order to enter the rootful container), which, by default, is done
118 using sudo (see docs for distrobox-enter on how to customize that).
119 However, for graphical apps in specific, since they launch without a
120 terminal, the usage of sudo might, at first, make it impossible to
121 launch them.
122
123 To fix this without needing to customize the sudo program, one can de‐
124 fine a global SUDO_ASKPASS environment variable on their machine, which
125 is a PATH to an executable that is run by sudo when no terminal is
126 available (or when it is given the --askpass or -A option), and the
127 output of that executable to stdout is used as the password input. The
128 executable is called as many times is needed for authentication as root
129 to succeed (unless a limit of amount of attempts is reached).
130
131 To do this, pick a program to ask the user for graphical password in‐
132 put. In this example, we will use zenity --password, which should be
133 present for GNOME users (and can also be installed in other DEs) -
134 there are other options, such as kdialog --password "Message" for KDE
135 users.
136
137 Write the call to the desired program to a script file, for example to
138 /usr/bin/my-password-prompt (sample contents below):
139
140 #!/bin/sh
141 zenity --password "Authentication as root is required"
142
143 (You may save the script under, for example, ~/.local/bin if you want
144 to keep it fully local to your user.)
145
146 Afterwards, make it executable (e.g. run sudo chmod +x /usr/bin/my-
147 password-prompt). Then, make sure to set SUDO_ASKPASS to "/usr/bin/my-
148 password-prompt" (replace with your script’s path) in a global profile
149 file, so that it is picked up by sudo when running graphical apps (and,
150 therefore, sudo will run the script you created to ask for a password).
151 This is done with the shell line export SU‐
152 DO_ASKPASS="/path/to/script/goes/here". You can do this for your user
153 only by running the command below (replace the script path as needed):
154
155 echo 'export SUDO_ASKPASS="/usr/bin/my-password-prompt"' >> ~/.profile
156
157 Which appends the appropriate line to the end of your ~/.profile file,
158 thus making the change local to your user. Alternatively, to set it
159 system-wide (for all users), you may create a file in /etc/profile.d/
160 (or equivalent for your system) with that line.
161
162 Now just log out and log back in, and graphical apps exported from
163 rootful containers should now be properly asking for root’s password
164 before launching (instead of not opening, if that was the case before).
165
166 Notes
167
168 Note you can use –app OR –bin OR –service but not together.
169
170 distrobox-export --service nginx --sudo
171
172 [IMAGE: app-export (https://user-images.githubusercon‐
173 tent.com/598882/144294795-c7785620-bf68-4d1b-b251-1e1f0a32a08d.png)]
174
175 [IMAGE: service-export (https://user-images.githubusercon‐
176 tent.com/598882/144294314-29a8921f-4511-453d-bf8e-d0d1e336db91.png)]
177
178 NOTE: some electron apps such as vscode and atom need additional flags
179 to work from inside the container, use the --extra-flags option to pro‐
180 vide a series of flags, for example:
181
182 distrobox-export --app atom --extra-flags "--foreground"
183
184
185
186Distrobox Dec 2022 DISTROBOX-EXPORT(1)