Matt
Matt

Reputation: 4387

Docker container as default application

I have Firefox nightly running in a container. I'm looking for a solution to configure it as my default browser application(ubuntu 18.04). So my question is, how to configure a Docker container as default system application in Ubuntu.

My docker command is:

docker run -d --net=host -v ~/:/home/firefox  -v /tmp/.X11-unix:/tmp/.X11-unix  \
  -e DISPLAY=unix:0 -v /dev/shm:/dev/shm --device /dev/snd \ 
  --group-add 29 -e PULSE_SERVER=unix:/run/user/1000/pulse/native \ 
  -v /run/user/1000/pulse/native:/run/user/1000/pulse/native \
  firefox-nightly

I suppose I must create a new mime file, but not sure how to do it, to be able to create the container with all these parameters.

Thanks

Upvotes: 1

Views: 763

Answers (1)

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10074

One alternative is to create a new .desktop file (e.g: /usr/share/applications/firefox-docker.desktop). I just copied the existing firefox.desktop and changed Exec sections with the command using docker (*)

Then use xdg-utils (**) configure it as default browser application: xdg-settings set default-web-browser firefox-docker.desktop.


*: To keep the .desktop file cleaner, you could create an executable file in system PATH (e.g: /usr/bin): docker-firefox:

xhost +
docker run --net=host -v ~/:/home/firefox  -v /tmp/.X11-unix:/tmp/.X11-unix  \
  -e DISPLAY=unix:0 -v /dev/shm:/dev/shm --device /dev/snd \ 
  --group-add 29 -e PULSE_SERVER=unix:/run/user/1000/pulse/native \ 
  -v /run/user/1000/pulse/native:/run/user/1000/pulse/native \
  firefox-nightly $@

Note the $@ at the end. And make it executable so it can be executed as a normal application.

**: The link is from Arch documentation, but it works in Ubuntu as well.

Upvotes: 2

Related Questions