Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forwarding to current port #136

Closed
tfeige91 opened this issue Oct 27, 2020 · 13 comments
Closed

Forwarding to current port #136

tfeige91 opened this issue Oct 27, 2020 · 13 comments

Comments

@tfeige91
Copy link

Hi,

I just tried running two sets of tests on the same server mapping to different ports:

First: docker run -d -p 80:80 expfactory/experiments --database "DATABASE" --experiments code,simple-reaction-time,stroop,go-nogo,bart,n-back,tower-of-london,kirby,flanker,stop-signal,reversal-learning,judgement-of-line-orientation-test,information-sampling start

Second: docker run --name="impulsivity" -d -p 3391:80 expfactory/experiments --database "DATABASE" --experiments code,simple-reaction-time,flanker,go-nogo,kirby,stop-signal,bart,stroop,information-sampling,reversal-learning start

Basically it works good but if you start the tests the forwarding leads you to SERVER:80 not SERVER:3391.
Is it possible to change that?

Thanks :)
Tim

@vsoch
Copy link
Member

vsoch commented Oct 27, 2020

For both of those, you mapped to port 80 on the host. If you want to have tests on a different port, you need to map to it. The way it works is like <port inside container>:<port on your host>

@tfeige91
Copy link
Author

Do I need to expose that Port in the dockerfile as well?
Should both of them not be mapped to 80?

@vsoch
Copy link
Member

vsoch commented Oct 27, 2020

Yes that's correct! Any port that you use from inside the container needs:

EXPOSE <port>
EXPOSE 3391

But since each container is isolated, what you really should care about are the ports you map to on the host (the second in the mapping). Using port 80 inside each of the containers should work best unless you are doing some significant change to services in the container that require running the expfactory server on another port.

@tfeige91
Copy link
Author

Hi Vanessa,
thanks for your help!

Unfortunately, mapping 80:3391 fails with Bind for 0.0.0.0:80 failed: port is already allocated.

Maybe I'm doing it wrong: Do I need to actually use docker build twice?

@vsoch
Copy link
Member

vsoch commented Oct 27, 2020

That means you have something else running on port 80, perhaps another container? Or nginx / apache on your host? What is your goal here - to run two different experiment servers at once on the same host? if you want to do that, you need to map each container to a different port on the host, e.g.,

80:3001 # map the container's internal port 80 to 3001 on your host
80:3002 # map the container's internal port 80 to 3002 on your host

@tfeige91
Copy link
Author

Hi Vanessa,
thanks to your help with my questions in autumn I managed to build a working system.
This here however I didn't get (right now I stop one container and start the other one when another test-system is needed - that writes into another database).

What i would love to achieve is having one set of tests under URL/testsystem1 and the other one under URL/testsystem2 OR
URL:Port1 / URL:Port2.
On the first look it works: I can see the different test-systems in the different ports but once there is any change in the site (e.g. if you start the tests) you are forwarded to Port 80.

The port mappings you suggested above leed to the sites not being accessible.

I used the dockerfile from this issue-post: #125

Might this be due to the nginx-configuration in the container?

Thanks for your help and kind regards!
Tim

@vsoch
Copy link
Member

vsoch commented Jan 21, 2021

The port needs to be exposed in the docker-compose.yml file too, and you likely need to tweak the DOMAIN_NAME in settings. Try both of those things (and sometimes you need to re-create the containers for it to work) and let me know if it works.

@tfeige91
Copy link
Author

I exposed the ports, but I don't know where to change the DOMAIN_NAME. Where are the settings ?

@vsoch
Copy link
Member

vsoch commented Jan 21, 2021

Should be these two lines https://github.com/expfactory/expfactory-docker/blob/master/expdj/settings.py#L19. Whether you rebuild or just bind and restart, you can shell into the container to double check that they are changed.

@tfeige91
Copy link
Author

Thanks for the super quick reply! Ah I see. By the way am i using the wrong version? This seems to be the one that has last been updated two years ago.

I always use this to build the container: docker build --no-cache -t expfactory/experiments .
Can I update this file from inside the container?

But this pulls from Dockerhub not quay.io , right?

@vsoch
Copy link
Member

vsoch commented Jan 21, 2021

Oh sorry - are you using the expactory-docker code in the repository here, or version 2 of expfactory (at https://expfactory.github.io)? Sorry they are different! If you can clarify which one, I can better help (I thought you were using the one here since the issue is posted here).

@tfeige91
Copy link
Author

Oh sorry, I use version 2 (the one at https://expfactory.github.io), although it says version 3.1 on the website. I didn't know there where differences by the time I created this issue.

@vsoch vsoch transferred this issue from expfactory/expfactory-docker Jan 21, 2021
@vsoch
Copy link
Member

vsoch commented Jan 21, 2021

Hmm, so the way that it works is that when you build your experiment container, internally everything is being served via port 5000, which is then proxy-ed to port 80 (or the same for https). So I suspect that if you want a different port used instead of 80, you'd need to change the nginx configuration there. It might be easiest to add a step to your Dockerfile to add a custom one e.g., see this step and then make sure that you expose the port, and definitely keep all your files in version control so you can reproduce your build.

And sorry for the confusion! I've transferred the issue to the correct repository. For some history, releases of expfactory through (I think) 2.5.47 or close to that were the original library, the one used for expfactory.org. The "version 2" of expfactory doesn't refer to 2.x, but to version 3.x and up (releases on pypi https://pypi.org/project/expfactory/). This is the one that builds containers for you with experiements.

@tfeige91 tfeige91 closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants