Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker open a url in the host browser

Tags:

docker

I have installed xdg-utils in my docker container using apt-get install xdg-utils

I want the command xdg-open 'http://www.freedesktop.org/' to open the specified url into the host browser.

right now it throws this error :

root@pravin:/# xdg-open 'http://www.freedesktop.org/'
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 778: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'http://www.freedesktop.org/'

How do I get docker to use the browser of the host os?

like image 692
node_man Avatar asked Jan 30 '19 09:01

node_man


People also ask

Can I open browser in Docker container?

Open https://localhost:5800 and access the firefox over the browser. Click on “Dashboard” to see what percentage of resources this Docker container is consuming: Click on the console sign just near to the stats to open browser.

Can I access localhost from Docker?

Accessing the Host With the Default Bridge Mode You just need to reference it by its Docker network IP, instead of localhost or 127.0. 0.1 . Your host's Docker IP will be shown on the inet line. Connect to this IP address from within your containers to successfully access the services running on your host.

Where is my Docker host URL?

It depends on your host, but look for /etc/default/docker or /var/lib/boot2docker/profile (for Docker Machine hosts using a boot2docker VM). Then get the IP address of the machine hosting your Docker daemon. (With a Docker Machine created host, that would be: docker-machine ip <yourmachine> .)


2 Answers

You can't, because container doesn't share with OS process/network namespace/filesystems by default.

In theory you can start container in the host process namespaces (--pid=host), network host namespace (--network=host) and mount required FS to the container (--volume ..), but still you may have another issues. That will require very advance Docker container skills.

like image 172
Jan Garaj Avatar answered Sep 19 '22 05:09

Jan Garaj


I think it may be hard to attach to host process and open new window.

There can be some solution that will overcome this difficulties. You can run browser process inside container and share display with host.

The main idea is to share DISPLAY environmental variable and network between host and container. More about this you can find in this great article .

like image 35
Konrad Avatar answered Sep 19 '22 05:09

Konrad