opened image

How to install SOCKS5 in Docker

To bypass numerous restrictions that may be related to your location, you can use the SOCKS technology. To ensure that no one is monitoring your traffic, you can use Wireguard VPN.

However, sometimes a VPN requires installing special client software on your personal computer or smartphone, for which you may not have sufficient rights. In this case, you can use a free alternative, the SOCKS 5 proxy tunnel.

In this article, we will discuss how to install it in a Docker container, also using docker-compose.
 

Let's install Docker. 

But first, you need to update the OS packages. 
 

apt update

Let's install the necessary packages and add a new repository:
 

apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"


Let's update the packages with the new repository:

 

 

 

apt update

 

Now let's install Docker itself.

 

 

 

 

apt-get install docker-ce docker-ce-cli containerd.io

 

Let's check the version:

 

 

 

 

docker --version

 


Let's check the status:

 

 

 

 

systemctl status docker

 



If it hasn't started, then start it:

 

 

 

 

systemctl start docker

 


And add it to the autostart.

 

 

 

 

systemctl enable docker

 


 

 

 

Let's install Docker-Compose


For this project, version 1.25 will be sufficient. 

 

 

 

 

 

curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

 

Let's set the execution rights. 

 

 

 

 

chmod +x /usr/local/bin/docker-compose

 

Let's check how Docker-Compose was installed:

 

 

 

 

docker-compose --version

 



Let's add the Linux user to the docker group:

 

 

 

 

usermod -aG docker $USER

 


Let's create a *.yaml  file for Docker-Compose.

To keep track of what we have installed in the future, let's create a separate folder for this project in the /home directory and navigate to it.

 

 

 

 

mkdir /home/socks5 && cd /home/socks5

 


You can also use another directory  to place this and other projects. 

Let's use the repository to create the docker-compose.yaml file at the link https://hub.docker.com/r/xkuma/socks5

Let's create the file docker-compose.yaml or docker-compose.yml,

 

 

 

 

vim docker-compose.yaml

 


And add the following code to it:

 

 

 

 

version: "2.1"
services:
  socks5:
    image: olebedev/socks5
    container_name: socks5_test
    environment:
      - PROXY_USER=your_user
      - PROXY_PASSWORD=your_pass
    ports:
      - 1080:1080/tcp
    restart: always

 


Where:

container_name: the name of your container;
PROXY_USER: user;
PROXY_PASSWORD: user password
1080:1080/tcp: the port on which SOCKS will operate.

Let's run the script (for this, you need to be in the directory where our file was created. In this case, it is /home/socks5/):

 

 

 

 

docker-compose up -d 

 


Wait for the images to download and deploy.
Let's check:

 

 

 

 

docker-compose ps

 


or 

 

 

 

 

docker ps

 



You can also do this with a single command without using docker compose.

 

 

 

 

docker run -d -p 1080:1080 -e PROXY_USER=your_user -e PROXY_PASSWORD=your_pass -e PROXY_SERVER=0.0.0.0:1080 xkuma/socks5

 


Now for the connection, you can use the login and password with the port and IP of your server. 

To check and ensure everything is set up correctly, we can use the command below on another server:

 

 

 

 

curl --socks5 your_user:[email protected]:1080 https://ifconfig.io

 


If everything is set up correctly, we will receive the IP of the server where our SOCKS5 is hosted.


For example, to connect SOCKS5 in Telegram, enter:

Server/Host: IP:1080
User: your_user
Password: your_pass


In browsers, Google Chrome or Firefox, you can use additional plugins to connect to this SOCKS5.

Wishing you safe surfing.