ilteoood / docker-surfshark

Docker container with OpenVPN client preconfigured for SurfShark
MIT License
133 stars 34 forks source link

Can't access from another container by service name. #58

Closed devXpro closed 1 year ago

devXpro commented 1 year ago

I have this config:

version: '3'
services:
  bot:
    restart: always
    build: .
  chrome:
    image: browserless/chrome
    network_mode: service:surfshark
  surfshark:
    image: ilteoood/docker-surfshark
    container_name: surfshark
    environment:
      - SURFSHARK_USER=$SURFSHARK_USER
      - SURFSHARK_PASSWORD=$SURFSHARK_PASSWORD
      - SURFSHARK_COUNTRY=es
      - CONNECTION_TYPE=udp
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
    restart: unless-stopped
    dns:
      - 1.1.1.1

I want to access the host 'chrome' from the 'bot' container using the service name, but it's not working. How can I fix this?

ilteoood commented 1 year ago

Hi @devXpro, you should define the LAN_NETWORK parameter: image

devXpro commented 1 year ago

@ilteoood I already tried that and it didn't help.

version: '3'
services:
  bot:
    restart: always
    build: .
  chrome:
    image: browserless/chrome
    network_mode: service:surfshark
  surfshark:
    image: ilteoood/docker-surfshark
    container_name: surfshark
    environment:
      - SURFSHARK_USER=$SURFSHARK_USER
      - SURFSHARK_PASSWORD=$SURFSHARK_PASSWORD
      - SURFSHARK_COUNTRY=es
      - CONNECTION_TYPE=udp
      - LAN_NETWORK=192.168.0.0/24
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
    restart: unless-stopped
    dns:
      - 1.1.1.1

I go inside the bot container and run wget http://chrome there, I get an error wget: bad address 'chrome'

ilteoood commented 1 year ago

that's because your browserless container is not anymore directly exposed to the network, as surfshark is acting like a proxy for it. You should, on the surfshark container, expose the port used by browserless (3000:3000 I guess), and then access it using the address the machine in which these are hosted.

You could also try accessing http://surfshark, but I don't know if it could work

devXpro commented 1 year ago

I just changed the host in the "bot" container from chrome to surfshark, and it worked! Thank you very much!