I've installed Magento in two Docker containers on a Mac, using the Docker install script provided by Magento. Docker provides two IP numbers, one for the host using 127.0.0.1 and a port number (32772 in this case, the exposed port number for the host), the other in the 172.x.x.x range (here 172.17.0.2).
I logged in, changed some trivial value. Then I committed both docker engines (Magento and Mysql) and saved them to a tar file. I loaded these files in docker on a Ubuntu 16.04 desktop. After some initial errors, and restarts of both docker engines it should have worked, but it fails on one point. When I load the website in a browser, it gets redirected to 127.0.0.1:32772, which doesn't work. Magento handles this redirect, so in a way it works.
Magento is setup to redirect to one URL. This URL or IP is set in a table and is set to the right value (172.17.0.2). Normally this means that the redirect should be to 172.17.0.2, port 80.
select * from core_config_data where path like '%base_url%';
The cache is cleared:
php bin/magento cache:clean && php bin/magento cache:flush
rm -rf var/cache/*
Browser cache is cleared (completely removed the .mozilla folder), tried a private window as well, and I installed another browser just to make sure.
On the magento2 docker container I installed elinks, a command line browser, and this opens the site and admin of magento using http://localhost. I see the admin login form. If I open the site in the host browser, it redirects from 172.17.0.2 to 127.0.0.1:32772, including a session ID. This means that magento runs and generates this session ID, but I don't understand the redirect.
Then there is this exposed port numer, 32772. This is the one that is set on the Mac, and I bet this is not the number that is used on the Ubuntu install.
- Why does the redirect keep happening?
- How can I get this site working properly?
- Where is the exposed port number set and can I change it for a running conatiner?
- How can I get the proper port number for the current container?