SoFunction
Updated on 2025-03-10

How to build chromium using docker

Using the Docker CLI

First, you need to make sure Docker is installed. The following is built using the Docker command line interface (CLI)linuxserver/chromiumSteps:

1. Pulllinuxserver/chromiumMirror:

docker pull linuxserver/chromium

This will pull the latest from Docker Hublinuxserver/chromiumMirror.

2. Create and start the container:

docker run -d \
  --name=chromium \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/London \
  -p 3000:3000 \
  --shm-size="2gb" \
  --restart unless-stopped \
  linuxserver/chromium

Parameter explanation:

  • -d: Run containers in the background.
  • --name: The name of the container must be unique in the same Docker environment.
  • -e: Set environment variables.
    • PUID: User ID, used for file permissions.
    • PGID: User group ID, same as above.
    • TZ: Sets the time zone of the container.
  • -p: Port map, format is <host port>: <container port>.
  • --shm-size: Sets the size of /dev/shm. Some applications (such as Chromium) may require larger shared memory.
  • --restart: Set the restart policy of the container. unless-stopped means that the container will automatically restart unless you explicitly stop it.
  • linuxserver/chromium: Specifies the image to run.

Using Docker Compose

For Docker Compose, you need to create aFile to define the service.

createdocument:

version: "3.8"
services:
  chromium:
    image: linuxserver/chromium
    container_name: chromium
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - /path/to/local/config:/config
    ports:
      - "3000:3000"
    shm_size: 2gb
    restart: unless-stopped

Parameter explanation:

  • version: Specifies the version of the Docker Compose file.
  • services: defines a list of services.
    • chromium: Service name.
    • image: Docker image used.
    • container_name: container name.
    • environment: List of environment variables.
    • volumes: volume map, format <host path>: <container path>.
    • ports: Port mapping list.
    • shm_size: shared memory size.
    • restart: Restart policy.

Start the service:

IncludedRun in the directory:

docker-compose up -d

This will be based onFile definition starts the service.

Notes:

  • Make sure that the PUID and PGID correspond to the actual user ID and group ID in your host system, which affects the file access rights of the running processes in the container to the mounted volume.
  • Adjust /path/to/local/config to the path to the local configuration directory you want to mount.
  • Adjust --shm-size and shm_size according to your needs to run the Chromium instance.
  • If you need to access Chromium through your browser, make sure the port mapping is correct and that the host's firewall settings allow access.
  • When using Docker Compose, if you want to stop and delete the service, you can use the docker-compose down command.
  • Please make sure the Docker and Docker Compose versions used are compatible with the versions defined in the file.

This is the end of this article about using docker to build chromium. For more related docker build chromium content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!