This guide provides instructions on how to build and run the surf browser on macOS using Docker and XQuartz. This method encapsulates all of surf's Linux dependencies within a Docker container.
- surf source code.
- Docker: Ensure you have Docker installed and the daemon is running. You can get it from the Docker website.
- XQuartz: This is an X11 server for macOS, which is required to display GUI applications running inside the container.
- Download and install it from the XQuartz website.
- After installation, you must log out and log back in for it to function correctly.
git clone git://git.suckless.org/surf
then add these docker files to the code.
Before running the application, you need to configure XQuartz to allow network connections:
- Open XQuartz.
- Go to
XQuartz->Preferencesin the menu bar. - Navigate to the Security tab.
- Ensure that the checkbox for "Allow connections from network clients" is checked.
- Restart XQuartz for the setting to take effect.
Open your regular macOS terminal (e.g., Terminal.app or iTerm2) and run the following command. This command allows your Docker container to connect to the XQuartz server on your host machine.
/opt/X11/bin/xhost +127.0.0.1Note: If you are using a different IP for your docker host, you may need to change this.
The project includes a Dockerfile that automates the build process.
Navigate to the project's root directory in your terminal and run the following command to build the image:
docker build -t surf-browser .Once the image is built, run the following command to start the surf browser:
docker run --rm -e DISPLAY="host.docker.internal:0" surf-browser--rm: Automatically removes the container when you close the application.-e DISPLAY="host.docker.internal:0": This tells the application inside the container to send its display to the XQuartz server running on your Mac.host.docker.internalis a special DNS name provided by Docker that resolves to your host machine's IP.
The surf browser window should now appear on your screen, open to the suckless.org homepage.