Chromium browser in Ubuntu 20.04 LTS without snap to use in docker container

Ubuntu team has its own vision for the snap (https://snapcraft.io/) service and that’s why they have moved the really big and difficult to maintain Chromium browser package in the snap package. Unfortunately, the snap has many issues with docker containers and in short, it is way difficult to run snap in a docker container. The user may just want not to mess with snap packages (despite this is the future according to the Ubuntu team) or like most developers they all need a browser for their tests executed in a container.
Whether you are a developer or an ordinary user this article is for you, who wants Chromium browser installed not from the snap service under Ubuntu 20.04 LTS!
There are multiple options, which could end up with a Chromium browser installed on the system, not from the snap service:

  1. Using Debian package and Debian repository. The problem here is that using simultaneously Ubuntu and Debian repository on one machine is not a good idea! Despite the hack, Debian packages are with low priority – https://askubuntu.com/questions/1204571/chromium-without-snap/1206153#1206153
  2. Using Google Chromehttps://www.google.com/chrome/?platform=linux. It is just a single Debian package, which provides Chromium-like browser and all dependencies requesting the Chromium browser package are fulfilled.
  3. Using Chromium team dev or beta PPA (https://launchpad.net/~chromium-team) for the nearest version if still missing Ubuntu packages for Focal (Ubuntu 20.04 LTS).
  4. more options available?

This article will show how to use Ubuntu 18 (Bionic) Chromium browser package from Chromium team beta PPA under Ubuntu 20.04 LTS (Focal). Bionic package from the very same repository of Ubuntu Chromium team may be used, too.

All dependencies will be downloaded from the Ubuntu 20.04 and just several Chromium-* packages will be downloaded from the Chromium team PPA Ubuntu 19 repository. The chances to break something are really small compared to the options 1 above, which uses the Debian packages and repositories. Hope, soon we are going to have focal (Ubuntu 20.04 LTS) packages in the Ubuntu Chromium team PPA!

Dockerfile

An example of a Dockerfile installing Chromium (and python3 selenium for automating web browser interactions)

RUN apt-key adv --fetch-keys "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111" \
&& echo 'deb http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic main ' >> /etc/apt/sources.list.d/chromium-team-beta.list \
&& apt update
RUN export DEBIAN_FRONTEND=noninteractive \
&& export DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -y install chromium-browser
RUN apt-get -y install python3-selenium

First command adds the repository key and the repository to the Ubuntu source lists. Note we are adding the “bionic main”, not “focal main”.
From the all dependencies of the Bionic chromium-browser only three packages are pulled from the Bionic repository and all other are from the Ubuntu 20 (Focal):

.....
Get:1 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main amd64 chromium-codecs-ffmpeg-extra amd64 84.0.4147.38-0ubuntu0.18.04.1 [1174 kB]
.....
Get:5 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main amd64 chromium-browser amd64 84.0.4147.38-0ubuntu0.18.04.1 [67.8 MB]
.....
Get:187 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main amd64 chromium-browser-l10n all 84.0.4147.38-0ubuntu0.18.04.1 [3429 kB]
.....

Here is the whole Dockerfile sample file:

#
#   Docker file for the image "chromium brower without snap"
#
FROM ubuntu:20.04
MAINTAINER myuser@example.com

#chromium browser
#original PPA repository, use if our local fails
RUN echo "tzdata tzdata/Areas select Etc" | debconf-set-selections && echo "tzdata tzdata/Zones/Etc select UTC" | debconf-set-selections
RUN export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NONINTERACTIVE_SEEN=true
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install gnupg2 apt-utils wget
#RUN wget -O /root/chromium-team-beta.pub "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111" && apt-key add /root/chromium-team-beta.pub
RUN apt-key adv --fetch-keys "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111" && echo 'deb http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic main ' >> /etc/apt/sources.list.d/chromium-team-beta.list && apt update
RUN export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NONINTERACTIVE_SEEN=true && apt-get -y install chromium-browser
RUN apt-get -y install python3-selenium

Desktop install

The desktop installation is almost the same as the Dockerfile above. Just execute the following lines:
Keep on reading!

Delay loading all pages in the Chromium and Google Chrome browsers tabs during start up and save a lot of memory

Recently we noticed our Chromium began to behavior really strange (we noticed it from Chromium version 69). When starting the Chromium browser the system tended to lag for 4-8 seconds and it was apparently connected with the browsers’ tabs opened in the previous session.
These days many people open multiple Internet pages in the browsers’ tabs and even more use the feature of

quitting the browser and then starting it back and the browser restores the previous session – all tabs with the pages loaded before.

. And time passes and we get used to open and leave more and more tabs, so not it is normal to have more than 30 opened page tabs in your browser, but last versions of the Chromium something has changed, because when you start the browser it completely loads all the pages, we do not think this was the case before so we dig it into the problem.
We use Chromium under (Gentoo) Linux and here is the problem:

top - 16:20:09 up 16 days, 16:36, 14 users,  load average: 4.77, 0.55, 0.43
Tasks: 288 total,  10 running, 201 sleeping,   0 stopped,   0 zombie
%Cpu(s): 82.6 us, 16.2 sy,  0.0 ni,  1.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8143960 total,  3012776 free,  3828732 used,  1302452 buff/cache
KiB Swap:  7606268 total,  6855752 free,   750516 used.  2554612 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                 
16082 myuser     20   0 3975632 371280 191940 S 106.9  4.6   0:05.86 /usr/lib64/chromium-browser/chrome --extra-plugin-dir=/usr/lib64/nsbrowser/plugins --ppapi-flash-path=+ 
16380 myuser     20   0 1779900 116276  76624 S  28.4  1.4   0:00.41 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16420 myuser     20   0 1777396 117096  85464 S  18.6  1.4   0:00.30 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16540 myuser     20   0 1850308 109576  76616 R  17.6  1.3   0:00.24 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16565 myuser     20   0 1769716 108588  81336 S  17.6  1.3   0:00.23 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16400 myuser     20   0 1775876 105220  76932 R  12.7  1.3   0:00.21 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16334 myuser     20   0 1770128 111588  83760 S  11.8  1.4   0:00.26 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
 5644 myuser      9 -11 3474604  11112   8368 S   9.8  0.1  14:50.60 /usr/bin/pulseaudio --start --log-target=syslog                                                         
16346 myuser     20   0 1772160 103924  76920 R   9.8  1.3   0:00.17 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16369 myuser     20   0 1772060 101696  74928 R   9.8  1.2   0:00.16 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16409 myuser     20   0 1783340 115752  77116 R   9.8  1.4   0:00.18 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16435 myuser     20   0 1770664 105088  81656 S   9.8  1.3   0:00.19 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16483 myuser     20   0 1772228 112008  83176 S   9.8  1.4   0:00.17 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16509 myuser     20   0 1772116 108544  81732 S   9.8  1.3   0:00.20 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16448 myuser     20   0 1771368 101300  74956 R   8.8  1.2   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16459 myuser     20   0 1692864 102668  80676 R   8.8  1.3   0:00.15 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16506 myuser     20   0 1766364  99588  78384 S   7.8  1.2   0:00.15 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16577 myuser     20   0 1767296 102268  80272 S   7.8  1.3   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
21462 myuser     20   0 2599480 493592  95284 S   7.8  6.1  17:00.39 /usr/lib64/firefox/firefox -contentproc -childID 13 -isForBrowser -prefsLen 51222 -schedulerPrefs 0001+ 
16417 myuser     20   0 1767568  99584  75992 R   5.9  1.2   0:00.12 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16530 myuser     20   0 1764332  99036  78768 S   5.9  1.2   0:00.11 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16341 myuser     20   0 1688088  96856  77776 S   4.9  1.2   0:00.09 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16395 myuser     20   0 1765648  96284  75132 S   4.9  1.2   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16464 myuser     20   0 1773864 104360  76260 S   4.9  1.3   0:00.12 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16467 myuser     20   0 1765740  96184  75520 S   4.9  1.2   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16491 myuser     20   0 1691968  96864  75744 S   3.9  1.2   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16496 myuser     20   0 1691964  97048  75852 S   3.9  1.2   0:00.18 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16501 myuser     20   0 1691492  92592  72604 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16578 myuser     20   0 1765432  93580  73868 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16587 myuser     20   0 1765416  93624  73856 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
28861 myuser     20   0 3503208 405676  91716 S   3.9  5.0  11:41.21 /usr/bin/firefox                                                                                        
16454 myuser     20   0 1617744  87852  70072 R   2.9  1.1   0:00.09 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16548 myuser     20   0 1692100  97336  76440 S   2.9  1.2   0:00.13 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
 5430 root      20   0  510884 133980 116036 S   2.0  1.6  39:33.10 /usr/bin/X -nolisten tcp -auth /var/run/sddm/{0c17f929-befd-402b-a80b-207e92f61272} -background none -+ 
16011 myuser     20   0  140316   3192   2632 R   2.0  0.0   0:00.44 top -d1                                                                                                 
 5193 root     -51   0       0      0      0 S   1.0  0.0  97:33.55 [irq/46-iwlwifi]                                                                                        
 5601 myuser     20   0 3422104  59664  23276 S   1.0  0.7  41:55.20 /usr/bin/kwin_x11 -session 10147150e9da000152673938100000083010144_1534452204_442575

As you can see starting Chromium it just flooded the system with hungry for CPU processes, so many that even a decent machine with 4 cores will get into troubles with 9 running Chromium process for a while! The load at the first seconds goes to 5-9 (as you can see here is 4.77 from below 1 – actually 0.5 ).
Keep on reading!