Docker Firefox

But you can use firefox inside your docker container. Follow the below given steps. Run xauth list command in your host machine and copy the cookies. [email protected] # xauth list vm1/unix:0 MIT-MAGIC-COOKIE-1 b4c39c85be9a907749dd9395f4175b0d. However, Docker has put a TON of time into containerd, which will still very much be used. In fact, Docker created the containerd project for a clean break-away from the core Docker engine. Really, the only thing that's changing is that middle layer: Kubernetes Docker Docker' and you still have everything else.

Docker Firefox

TaskCluster Docker images are defined in the source directory undertaskcluster/docker. Each directory therein contains the name of animage used as part of the task graph.


Each folder describes a single docker image. We have two types of images that can be defined:

  1. Task Images (build-on-push)

  2. Docker Images (prebuilt)

These images depend on one another, as described in the FROM line at the top of theDockerfile in each folder.

Images could either be an image intended for pushing to a docker registry, orone that is meant either for local testing or being built as an artifact whenpushed to vcs.

Task Images (build-on-push)¶

Images can be uploaded as a task artifact, indexed undera given namespace, and used in other tasks by referencing the task ID.

Important to note, these images do not require building and pushing to a docker registry, and arebuilt per push (if necessary) and uploaded as task artifacts.

The decision task that is run per push will determineif the image needs to be built based on the hash of the context directory and if the imageexists under the namespace for a given branch.

As an additional convenience, and a precaution to loading images per branch, if an imagehas been indexed with a given context hash for mozilla-central, any tasks requiring that imagewill use that indexed task. This is to ensure there are not multiple images built/usedthat were built from the same context. In summary, if the image has been built for mozilla-central,pushes to any branch will use that already built image.

To use within an in-tree task definition, the format is:


Context Directory Hashing¶

Decision tasks will calculate the sha256 hash of the contents of the imagedirectory and will determine if the image already exists for a given branch and hashor if a new image must be built and indexed.

Note: this is the contents of only the context directory, not theimage contents.

Run Firefox In Docker Container

The decision task will:

  1. Recursively collect the paths of all files within the context directory

  2. Sort the filenames alphabetically to ensure the hash is consistently calculated

  3. Generate a sha256 hash of the contents of each file

  4. All file hashes will then be combined with their path and used to update thehash of the context directory

This ensures that the hash is consistently calculated and path changes will resultin different hashes being generated.

Task Image Index Namespace¶

Images that are built on push and uploaded as an artifact of a task will be indexed under thefollowing namespaces.

  • gecko.cache.level-{level}.docker.v2.{name}.hash.{digest}

  • gecko.cache.level-{level}.docker.v2.{name}.latest

  • gecko.cache.level-{level}.docker.v2.{name}.pushdate.{year}.{month}-{day}-{pushtime}

Not only can images be browsed by the pushdate and context hash, but the ‘latest’ namespaceis meant to view the latest built image. This functions similarly to the ‘latest’ tagfor docker images that are pushed to a registry.

Docker Registry Images (prebuilt)¶

*Warning: Registry images are only used for ``decision`` and``image_builder`` images.*

These are images that are intended to be pushed to a docker registry and usedby specifying the docker image name in task definitions. They are generallyreferred to by a <repo>@<repodigest> string:


Such images must always be referred to with both a version and a repo digest.For the decision image, the repo digest is stored in the HASH file in theimage directory and used to refer to the image as above. The version for bothimages is in VERSION.

The version file serves to help users identify which image is being used, and makes oldversions easy to discover in the registry.

The file taskcluster/docker/REGISTRY specifies the image registry to whichthe completed image should be uploaded.

Docker Hashes and Digests¶

Docker Linux Mint

There are several hashes involved in this process:

  • Image Hash – the long version of the image ID; can be seen withdockerimages--no-trunc or in the Id field in dockerinspect.

  • Repo Digest – hash of the image manifest; seen when running dockerpush or dockerpull.

  • Context Directory Hash – see above (not a Docker concept at all)

The use of hashes allows older tasks which were designed to run on an olderversion of the image to be executed in Taskcluster while new tasks use the newversion. Furthermore, this mitigates attacks against the registry as dockerwill verify the image hash when loading the image.

(Re)-Building images¶

Docker Firefox Vnc

Generally, images can be pulled from the Docker registry rather than builtlocally, however, for developing new images it’s often helpful to hack on themlocally.

To build an image, invoke machtaskcluster-build-image with the name of thefolder (without a trailing slash):

This is a wrapper around dockerbuild-t$REGISTRY/$FOLDER:$VERSION.

It’s a good idea to bump the VERSION early in this process, to avoiddockerpush-ing over any old tags.

For task images, test your image locally or push to try. This is all that isrequired.

Docker Registry Images¶

Landing docker registry images takes a little more care.

Begin by bumping the VERSION. Once the new version of the image has beenbuilt and tested locally, push it to the docker registry and make note of theresulting repo digest. Put this value in the HASH file for thedecision image and in taskcluster/taskgraph/transforms/docker_image.pyfor the image_builder image.

The change is now safe to use in Try pushes.

Note that image_builder change can be tested directly in try pushes withoutusing a registry, as the in-registry image_builder image is used to build atask image which is then used to build other images. It is referenced by hashin taskcluster/taskgraph/transforms/

Special Dockerfile Syntax¶

Dockerfile syntax has been extended to allow any file from thesource checkout to be added to the image build context. (Traditionallyyou can only ADD files from the same directory as the Dockerfile.)

Simply add the following syntax as a comment in a Dockerfile:



Docker Firefox Selenium

# %include mach# %include testing/mozharness

The argument to #%include is a relative path from the root level ofthe source directory. It can be a file or a directory. If a file, only thatfile will be added. If a directory, every file under that directory will beadded (even files that are untracked or ignored by version control).

Files added using #%include syntax are available inside the buildcontext under the topsrcdir/ path.

Files are added as they exist on disk. e.g. executable flags should bepreserved. However, the file owner/group is changed to root and themtime of the file is normalized.

Here is an example Dockerfile snippet:

Run Firefox or Google Chrome into a Docker container based on
FROM ubuntu:14.04
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 &&
mkdir -p /home/developer &&
echo 'developer:x:${uid}:${gid}:Developer,:/home/developer:/bin/bash' >> /etc/passwd &&
echo 'developer:x:${uid}:' >> /etc/group &&
echo 'developer ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/developer &&
chmod 0440 /etc/sudoers.d/developer &&
chown ${uid}:${gid} -R /home/developer
RUN apt-get update && apt-get install -y firefox wget
RUN wget -q -O - sudo apt-key add -
RUN echo 'deb stable main' >> /etc/apt/sources.list.d/google.list
RUN apt-get update
RUN apt-get install google-chrome-stable dbus-x11 packagekit-gtk3-module libcanberra-gtk-module -y
USER developer
ENV HOME /home/developer
CMD dbus-daemon --system --fork && /usr/bin/firefox
docker build -t browser .
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix browser
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix browser google-chrome

commented Oct 26, 2015

Now check

commented Mar 6, 2018

commented Sep 1, 2019

Docker Firefox Selenium

Is there a way to make this work with later versions of ubuntu, say 16.04 or 18.04? Getting error stuck on line /sudoers.d/ directory doesn't exist?


commented Jul 18, 2020

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment