Install docker on debian
First install this packages :
1
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Then add this line
deb https://download.docker.com/linux/debian stretch stable
to `/etc/apt/source.list- Add the key to apt :
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
- Update package list and install docker :
1
sudo apt-get update && sudo apt-get install docker-ce
Write the docker file
- This docker is based on debian stable, so we just have to install chromium, add a user and configure the sound from the container.
- To write the docker file, create a empty dir and create a file named
Dockerfile
:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16FROM debian:stable
SHELL ["/bin/bash", "-c"]
# Packages needed for chromium and add a conf line in pulse
RUN apt-get update && apt-get install -yq --no-install-recommends \
chromium libcurl3 libgl1-mesa-dri libcanberra-gtk-module libexif-dev pulseaudio \
&& rm -rf /tmp/* /var/{tmp,cache}/* /var/lib/{apt,dpkg}/ \
&& echo enable-shm=no >> /etc/pulse/client.conf
# Create a group and a user with same id of host user
RUN groupadd -f -g 1000 user
RUN adduser --uid 1000 --gid 1000 --disabled-login --gecos 'User' user
ENV HOME /home/user
# Conf for sound
ENV PULSE_SERVER /run/pulse/native
# The command that run chromium with the home page
CMD ["chromium","--no-sandbox", "--no-first-run","http://google.com"]
Build the docker image
1 | docker build -t chromium . |
Run docker
Command to run :
1
2
3
4
5
6
7
8
9
10
11
12
13#!/bin/bash
USER_UID=$(id -u)
USER_GID=$(id -g)
xhost +local:docker
docker run -t --net host --rm -e DISPLAY=$DISPLAY \
--env=USER_UID=$USER_UID \
--env=USER_GID=$USER_GID \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-v /run/user/$USER_UID/pulse:/run/pulse:ro \
--device /dev/snd \
chromiumDetails :
--net host
: for having network-e DISPLAY:$DISPLAY
: for having GUI on hostUSER_(U|G)ID
: for having good user and group/tmp/.X11-unix:/tmp/.X11-unix:ro
: connecting X socket between host and container/run/user/$USER_UID/pulse:/run/pulse:ro
and--device /dev/snd
: for having sound