[Solved] Access URL from separate container

I have two separate containers running on a Rpi3, one of which uses the base image from the Balena WPE example in order to get the Webkit browser running. I have a separate service running that’s running a webpack dev server. I can’t seem to access the URL from the webpack container, despite having exposed the ports. I can access the page from the URL on my local network using the <ip>:<port>.

From this post: Docker-compose network service names not resolving correctly it was my understanding that I’d be able to access the page hosted by the other container using the service name, eg. <service_name>:<port>, or am I mistaken?

Hi @craigson
That is right, it should work. I sounds as if adding network configuring might get in the way of this for some users. Have you got networks configured ?
To be able to help you further it would be good to know what release of balena OS you are working with and what your docker compose file looks like…
Regards
Thomas

Hi @samothx,

BalenaOS: balenaOS 2.36.0+rev2

docker-compose.yml:

version: '2'

services:
  server:
    build:
      context: ./apps/server
      dockerfile: Dockerfile.template
    privileged: true
    stdin_open: true
    tty: true

  kiosk-browser:
    restart: always
    build:
      context: ./apps/kiosk
      dockerfile: Dockerfile
    privileged: true
    depends_on:
      - server
    # ports:
    #   - 8080:8080

  kiosk-app:
    build:
      context: ./apps/client
      dockerfile: Dockerfile.template
      args:
        NPM_TOKEN: ${NPM_TOKEN}
    env_file:
      - .env
    privileged: true
    ports:
      - 9045:9045

@craigson First of all, there are some unsupported fields that you have specified in your docker-compose (tty and stdin_open), as noted here: https://www.balena.io/docs/reference/supervisor/docker-compose/. I see you have three services, which one are you trying to access from which one? Maybe you can try explicitly setting network_mode: host for each service, and using expose instead of ports for the one that is only accessed internally. As far as I am aware, it should work as it is, but it is good to try if setting the network mode will maybe solve the problem.

Hi @sradevski,
Either adding the network_mode or exposing the port seemed to do the trick. All that was left was to set the WPE_URL to point to localhost.

Thanks for the help.

Hey @craigson, glad I could help. If you need any further assistance, feel free to reach to us and the community on the forums.