Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Unable to set SELENIUM_NODE_HOST to {{CONTAINER_IP}} when using swarm/stack #236

Closed
KZachariassen opened this issue May 4, 2018 · 6 comments

Comments

@KZachariassen
Copy link
Contributor

KZachariassen commented May 4, 2018

Hi,

I'm trying to deploy selenium on my docker swarm using stack, the problem here is that stack uses go template and will evaluate {{CONTAINER_IP}} on the deployment time. There is currently no way to escape this, so my question is: Could you set the default value of SELENIUM_NODE_HOST
to {{CONTAINER_IP}} so if I don't specify SELENIUM_NODE_HOST in my compose, it will be {{CONTAINER_IP}}?

docker-compose.yml

version: '3.4'

services:
  chrome:
    image: elgalu/selenium
    environment:
      - PICK_ALL_RANDOM_PORTS=true
      - SELENIUM_HUB_HOST=hub
      - SELENIUM_HUB_PORT=4444
      - SELENIUM_NODE_HOST={{CONTAINER_IP}}
      - VNC_FROM_PORT=${VNC_FROM_PORT-40650}
      - VNC_TO_PORT=${VNC_TO_PORT-40700}
      - SCREEN_WIDTH=1300
      - SCREEN_HEIGHT=999
      - VIDEO=${VIDEO-false}
      - GRID=false
      - CHROME=true
      - FIREFOX=false

docker stack deploy -c .\docker-compose.yml selenium
failed to update service selenium_chrome: Error response from daemon: rpc error: code = InvalidArgument desc = expanding env failed: expanding env "SELENIUM_NODE_HOST={{CONTAINER_IP}}": template: expansion:1: function "CONTAINER_IP" not defined

Operating System

Image version

  • [latest]

Docker version

  • [Docker version 17.12.1-ce, build 7390fc6]
KZachariassen added a commit to KZachariassen/docker-selenium that referenced this issue May 4, 2018
@KZachariassen
Copy link
Contributor Author

I have solved this really simple(and maybe dirty)
master...krjensen:patch-1

This gives the value USE_CONTAINER_IP the same logic as {{CONTAINER_IP}}

@elgalu
Copy link
Owner

elgalu commented May 4, 2018

Good point, we didn't foresee that this would conflict with templating systems in the future. I'm fine with accepting this as a pull request but I would rename USE_CONTAINER_IP with __CONTAINER_IP__

@KZachariassen
Copy link
Contributor Author

Thank you! I have created a PR.

elgalu pushed a commit that referenced this issue May 4, 2018
* To solve issue 236

Solves: #236

* Changed to __CONTAINER_IP__
@elgalu
Copy link
Owner

elgalu commented May 5, 2018

@elgalu elgalu closed this as completed May 5, 2018
jemacom added a commit to jemacom/docker-selenium that referenced this issue Jul 30, 2018
@uzdik-student
Copy link

It took me several hours to figure out this issue on docker swarm, I think it would be great if this solution would be included in docker-compose.md file.

@diemol
Copy link
Collaborator

diemol commented May 11, 2019

@algakzru feel free to send us a PR to add it there 👍

elgalu pushed a commit that referenced this issue Nov 24, 2020
Workaround described in #236
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants