The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mancocapac (15) [Avatar] Offline
#1
I have a couple of issues:

1. I think "gui" needs to be the last item on the command line

my "runit.sh" bash script:

#!/bin/bash

docker run \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -e DISPLAY=$DISPLAY \
  -h $HOSTNAME \
  -v $HOME/.Xauthority:/home/$USER/.Xauthority \
  gui


The above works for me but, I still get

Gtk-Message: Failed to load module "canberra-gtk-module"

2. This brings up Firefox, but
The FF that comes up has all of my Bookmarks, tabs, ... etc - why?
FF version 47.0 -
With Firefox, for example, you might want to see how your application
behaves with no web cache, bookmarks, or search history in a repeatable way for test-
ing purposes.

mancocapac (15) [Avatar] Offline
#2
Update on firefox starting with my bookmarks ... etc

After some googling I found: http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
buried in the comment section I found: see DJon, Oded Arbel comments
Its a "feature" of Firefox - when you start Firefox it checks to see if there is another Firefox running that it can communicate with, which it does using the X11 protocol, and if so it creates a new window with the existing Firefox instance.


So, If I exit (all) my Firefox windows and then do a docker run I get a fresh FF.
A slight gotcha here is I am directed to FF config pages, not really what I want.

My goal is similar to your statement: "... With Firefox, ... you may want to see how your app behaves with no web cache..."
It looks like part of the solution is to use firefox command line option '-P' for profile.
I found this: https://github.com/chrisdaish/docker-firefox see launch commands, where he is mounting my profile
in read-only mode. This is not quite what I want. I'd like to create a separate profile for testing, keep a "virgin" copy on my host
and copy it to the container.

any thoughts on how I can do this?

BTW: Jessie Frazelle is a another resource on this topic: see https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
see GUIs/Chrome

mancocapac (15) [Avatar] Offline
#3
Here is what I did:

1) /path-to-my-container/firefox-docker

firefox -P "Tester" -profile "./profile/tester"   # creates a new profile on my host
cd profile
tar -czf tester-profile-ff.tar.gz tester/


2) changes to the Dockerfile
FROM ubuntu:14.04

RUN apt-get update \
    && apt-get install -y firefox 

RUN groupadd \
    -g 1000 tester
RUN useradd \
    -d /home/tester \
    -s /bin/bash \
    -m tester \
    -u 1000 \
    -g 1000
USER tester
ENV HOME /home/tester
RUN mkdir -p /home/tester/profile
ADD ./profile/tester-profile-ff.tar.gz /home/tester/profile
RUN chown -R tester:tester /home/tester/profile
CMD /usr/bin/firefox -new-instance -P "Tester" -profile "/home/tester/profile/tester"


build the image:
docker build -t gui .


runit.sh
#!/bin/bash

docker run \
  --rm \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -e DISPLAY=$DISPLAY \
  -h $HOSTNAME \
  -v $HOME/.Xauthority:/home/$USER/.Xauthority \
  gui


power it up
 ./runit.sh &   # put it in the background, so I can run a bunch if I want to


check docker ps
docker ps 
CONTAINER ID     IMAGE     COMMAND                  CREATED             STATUS              PORTS  NAMES
8ab95fbaaaaa      gui        "/bin/sh -c '/usr/bin"   15 seconds ago      Up 13 seconds                silly_goldwasser
bceb4a3bbbbb     gui         "/bin/sh -c '/usr/bin"   23 seconds ago      Up 22 seconds                agitated_pike
040b2c9ccccc      gui         "/bin/sh -c '/usr/bin"   3 minutes ago       Up 3 minutes                    stoic_jones


NOTE:
- I'm not quite sure how .Xauthority works in this case, as I am "me" on the host and "tester" on the container
- After running for a few minutes, I see a bunch of warnings from firefox on my host. I seems to be related to
the profile I copied to the container. Probably have to look more into the initialization of the profile, before
copying it. The warnings are having to do with ... updates property ...