I’m using docker for my development environment, I correctly linked my database container with my webserver container as many other local websites (on other frameworks) are accessing it flawlessly (the alias is simply “db” usually in the .env file).
However, with bedrock, just cloned from the bedrock repo, I get the following error:
We were able to connect to the database server (which means your username and password is okay) but not able to select the /docker_web_1/db database.
My .env file however states:
Of course, the “bedrock” database, the username, password and host do exist, but for some reason it seems that bedrock is trying to load a db called “/docker_web_1/db” (“docker_web_1” is the name of the webserver container, “db” is the host of the database - the database is supposed to be called “bedrock”). It seems the DB_NAME is ignored and replaced with other parameters.
A “normal” install of wordpress with the same environment and parameters works perfectly.
Any idea how to solve this issue?
Thanks in advance!
Since Bedrock uses PHP dotenv, maybe it’s something to do with that? Not sure though, I’ve never used Docker in this fashion.
Bedrock really isn’t doing anything different with the WP constants other than using environment variables. You could try changing this here to your database name, and if it works, would identify if using PHP dotenv is the issue in the stack.
Indeed, that seems to be the problem here. Not sure why every other env variables worked but not that one though…
I’ll check the dotenv doc to adjust my docker environment then!
I would ask @etc how he rigs his bedrock with docker.
Most likely because you’ve already set the env variables DB_USER and DB_NAME.
So either reconfigure your Docker container to use different var names or change the name of the env variables bedrock is looking for and update your .env file accordingly.
P.S. This has nothing to do with Bedrock.
Interesting. I’m not setting the DB_NAME myself elsewhere, but it turns out the container I’m using for my DB does… Very good point, thanks!
@etc - Can you share your docker-based repo for bedrock?
I’d like to setup bedrock using docker and I have not been able to get it to work with bedrock.
I’m using docker-compose, here is what it looks like:
Hey @btamm, sorry for the late reply. I’ve been traveling.
What I typically do is just use separate hhvm, mysql, redis, nginx, etc instances and then use shared volumes between the different services. I use Capistrano to deploy each build to the server. I can show you what that stack looks like if you’d like. The reason I haven’t released it yet is because I don’t like the configuration method I’m using. Right now, I end up just linking a server config file to each of the containers. I’d working on getting a Bedrock compatible nginx container that uses docker-gen and environment variables for full configuration.
Would this be useful to you?
Thank you for the response! I’d certainly like to see the stack.
I prefer docker over vagrant/ansible because I mainly develop on dockerized versions of magento and I’d like to eliminate vagrant/ansible so I have less dependencies, less overhead, less to learn or remember, and less manual steps involved. I’ve got new projects down to changing environmental variables and 5 lines of code to spin up dev/prod/staging
@btamm @etc, could you share the stack here also please? I’m justing starting to use bedrock and would also like to use it in a docker environment.
Is this thread still alive or should we start a new definitive Docker thread?
I ask as I’m looking to move to Docker as well, now that the toolset has improved and stabilised somewhat. It also looks to run much faster than my Vagrant based Roots setup.
The real question for me though is: What is the workflow that will allow me to stay up to date with Roots/Trellis?
For example, the steps to do so seem to be as follows?
- Create WP database and PHP WordPress code on a local Vagrant/VirtualBox laptop from scratch using standard Trellis workflow.
- Dump and migrate Trellis WordPress DB to a WordPress Apache Docker instance which also picks up Trellis generated WordPress PHP code.
As I go on, to stay up to date I need to fetch upstream Trellis changes and repeat the above process, using database backups so I don’t lose any content?
So, what’s a bombproof, repeatable workflow we can use to bridge the Trellis/Docker gap…?