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

Docker compose environment variables not taking affect after initial setup #189

Closed
volt3 opened this issue Nov 22, 2017 · 5 comments
Closed

Comments

@volt3
Copy link

volt3 commented Nov 22, 2017

Hello!

TLDR: MYSQL_HOST does not modify dbhost inside config.php after initial setup.

I modified the basic docker compose file suggested in the README by adding the following:

services:
  db:
    ports:
      - 8081:3306

Now that I understand compose creates a network between the services and I do not need to expose the port to host, I removed the above and understand that the following is sufficient.

services: 
  app:
    links:
      - db

However this did not modify dbhost inside /html/config.php as expected.

I added the following to the docker-compose.yml:

services:
  app:
    environment:
      MYSQL_DATABASE=XXXX
      MYSQL_USER=XXXX
      MYSQL_PASSWORD=XXXX
      MYSQL_HOST=db

And this did not modify dbhost, it was still the same value as initial setup.

I fixed my problem by modifying dbhost to just db.

Problems

  • As the docker-compose file does not seem to have precedence(after the initial setup), if I change the service name from db to nextcloudDataBase, and links: to nextcloudDataBase it breaks the deployment although docker-compose networks will be able to resolve http://nextcloudDataBase
  • I naturally expect/assume/define that when I set MYSQL_HOST within docker-compose it will look for the correct host after a container has been removed and recreated.

Question

  1. Although changing the dbhost fixed my network issue, is MYSQL_HOST intended to modify any other variable/aspect of the system?

Thank you for your time.

@SnowMB
Copy link
Contributor

SnowMB commented Nov 23, 2017

Hello,

I hope I can clarify things a bit. As you found out, the environment variables are only used by the initial setup. This is intended and by design. It might not be the best solution, but it was the easier one. I see that many other services handle things a little differently, so we might have a chance to improve here.

For your problem there are two solutions:

If you are trying to get a new installation of nextcloud running and have no data that could be lost, you can just start from scratch. But be careful, stopping and recreating containers will preserve the data! To actually delete the screwed up configuration you have to explicitly tell docker to remove the volumes where your data and configuration is stored. You can achieve this by adding the -v flag to docker-compose down -v. Or you can manually remove the volumes by using the following commands:

docker volume ls 
docker volume rm <NAME>

If you want to keep your data, the only way to fix your setting is editing your config.php manually. Check out the nextcloud docs for the correct parameters.

@SnowMB SnowMB closed this as completed Nov 23, 2017
@SnowMB
Copy link
Contributor

SnowMB commented Nov 23, 2017

Sorry for closing...

@SnowMB SnowMB reopened this Nov 23, 2017
@volt3
Copy link
Author

volt3 commented Nov 24, 2017

Thank you for your time.

I have done the changes I needed and am very happy with the current install.

@evertramos
Copy link

Hello @volt3,

Just to answer your final question the MYSQL_HOST only changes the ./config/config.php as you probably already know by now.

@SnowMB think you can close this issue.

@SnowMB
Copy link
Contributor

SnowMB commented Dec 19, 2017

Yeah, think so to. Reopen if another related question occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants