Clash
Docker
Docker image: https://hub.docker.com/r/dreamacro/clash
Create a new folder, and write a docker-compose.yaml
with the following content.
- POSIX
- Windows
docker-compose.yaml
services:
clash:
image: dreamacro/clash
container_name: clash
volumes:
- ./config.yaml:/root/.config/clash/config.yaml
# - ./ui:/ui # dashboard volume
restart: unless-stopped
network_mode: "host"
docker-compose.yaml
services:
clash:
image: dreamacro/clash
container_name: clash
volumes:
- ./config.yaml:/root/.config/clash/config.yaml
# - ./ui:/ui # dashboard volume
ports:
- "7890:7890"
- "7891:7891"
# - "8080:8080" # external controller (Restful API)
# TUN
# cap_add:
# - NET_ADMIN
# devices:
# - /dev/net/tun
restart: unless-stopped
network_mode: "bridge"
Then put the config.yaml
under the same folder.
Run the following command to start the Clash.
docker compose up --detach
Run the following command to stop the Clash.
docker compose down
Now export following environment variables.
export http_proxy="http://localhost:7890"
export https_proxy="http://localhost:7890"
export all_proxy="socks5://127.0.0.1:7891"
You can append the commands above to the bashrc file.
For all users:
sudo nano /etc/bash.bashrc
source /etc/bash.bashrc
For current user:
sudo nano ~/.bashrc
source ~/.bashrc
Then you can test the proxy.
curl https://www.google.com