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:

myuser@srv:~# sudo apt-key adv --fetch-keys "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111" \
 && sudo echo 'deb http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic main ' >> /etc/apt/sources.list.d/chromium-team-beta.list \
 && sudo apt update
Executing: /tmp/apt-key-gpghome.QgCEH2jXlU/gpg.1.sh --fetch-keys https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111
gpg: requesting key from 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xea6e302dc78cc4b087cfc3570ebea9b02842f111'
gpg: key 0EBEA9B02842F111: public key "Launchpad PPA for Chromium team" imported
gpg: Total number processed: 1
gpg:               imported: 1
Hit:1 http://nl.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://nl.archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]                             
Get:3 http://nl.archive.ubuntu.com/ubuntu focal-backports InRelease [98,3 kB]                                                           
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]       
Get:5 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic InRelease [21,3 kB]
Get:6 http://nl.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [93,8 kB]
Get:7 http://nl.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [177 kB]
Get:8 http://nl.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [69,7 kB]
Get:9 http://nl.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [102 kB]
Get:10 http://nl.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [5248 B]
Get:11 http://nl.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [8924 B]
Get:12 http://nl.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [2516 B]
Get:13 http://nl.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [102 kB]
Get:14 http://nl.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [55,2 kB]
Get:15 http://nl.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [46,8 kB]
Get:16 http://nl.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [143 kB]
Get:17 http://nl.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [3704 B]
Get:18 http://nl.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [532 B]
Get:19 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main i386 Packages [1604 B]
Get:20 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [32,6 kB]
Get:21 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [93,7 kB]
Get:22 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main amd64 Packages [1608 B]
Get:23 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [36,1 kB]                         
Get:24 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [18,7 kB]                      
Get:25 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [2612 B]                                  
Get:26 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [8924 B]                              
Get:27 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [2516 B]                          
Get:28 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [33,4 kB]                                
Get:29 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [10,3 kB]                            
Get:30 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [16,1 kB]                    
Get:31 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [31,6 kB]
Get:32 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [1356 B]  
Get:33 http://ppa.launchpad.net/chromium-team/beta/ubuntu bionic/main Translation-en [1056 B]
Fetched 1436 kB in 1s (1208 kB/s)          
Reading package lists... Done
Building dependency tree       
Reading state information... Done
62 packages can be upgraded. Run 'apt list --upgradable' to see them.
myuser@srv:~# sudo apt-get -y install chromium-browser
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  chromium-browser-l10n chromium-codecs-ffmpeg-extra
Suggested packages:
  webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
The following NEW packages will be installed:
  chromium-browser chromium-browser-l10n
The following packages will be upgraded:
  chromium-codecs-ffmpeg-extra
1 upgraded, 2 newly installed, 0 to remove and 61 not upgraded.
Need to get 72,4 MB of archives.
After this operation, 243 MB of additional disk space will be used.
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:2 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:3 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]                                                 
Fetched 72,4 MB in 15s (4757 kB/s)                                                                                                                                                           
(Reading database ... 187615 files and directories currently installed.)
Preparing to unpack .../chromium-codecs-ffmpeg-extra_84.0.4147.38-0ubuntu0.18.04.1_amd64.deb ...
Unpacking chromium-codecs-ffmpeg-extra (84.0.4147.38-0ubuntu0.18.04.1) over (81.0.4044.129-0ubuntu0.20.04.1) ...
Selecting previously unselected package chromium-browser.
Preparing to unpack .../chromium-browser_84.0.4147.38-0ubuntu0.18.04.1_amd64.deb ...
Unpacking chromium-browser (84.0.4147.38-0ubuntu0.18.04.1) ...
Selecting previously unselected package chromium-browser-l10n.
Preparing to unpack .../chromium-browser-l10n_84.0.4147.38-0ubuntu0.18.04.1_all.deb ...
Unpacking chromium-browser-l10n (84.0.4147.38-0ubuntu0.18.04.1) ...
Setting up chromium-codecs-ffmpeg-extra (84.0.4147.38-0ubuntu0.18.04.1) ...
Setting up chromium-browser (84.0.4147.38-0ubuntu0.18.04.1) ...
Setting up chromium-browser-l10n (84.0.4147.38-0ubuntu0.18.04.1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu2) ...

Throubleshooting – snap install of Chromium in Docker

This is the original problem – at present, the snap store does not work executed in docker, so apt cannot Chromium browser.

In fact, the installation just hangs in checking connectivity with the snap store.

Setting up systemd-timesyncd (245.4-4ubuntu3.1) ...
Created symlink /etc/systemd/system/dbus-org.freedesktop.timesync1.service → /lib/systemd/system/systemd-timesyncd.service.
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.
Selecting previously unselected package chromium-browser.
(Reading database ... 6499 files and directories currently installed.)
Preparing to unpack .../00-chromium-browser_81.0.4044.129-0ubuntu0.20.04.1_amd64.deb ...
=> Installing the chromium snap
==> Checking connectivity with the snap store
===> Unable to contact the store, trying every minute for the next 30 minutes
^C

And the package is never installed.

Leave a Reply

Your email address will not be published. Required fields are marked *