-
Notifications
You must be signed in to change notification settings - Fork 203
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
The bad situation with bind volumes #263
Comments
The volume has data to get started quickly. If you bind your own folder, it would use that folder instead of the image one |
Yeah but I want to store my Drupal data on a folder in my filesystem and if I use a bind volume to do so Drupal's data will be replaced with nothing. The container should simply copy the data from another folder which isn't binded to the folder that is binded and probablem solved. |
For what it's worth, we do something like this in the farmOS Docker image (which extends from Then, to handle bind-mounted volumes (which are empty when the container first starts), we use a custom https://github.com/farmOS/farmOS/blob/3.x/docker/docker-entrypoint.sh This serves us well. However it is somewhat custom to our use-case, and an entrypoint script seems to be the only way to achieve it. It's not possible to do this in the That means that in order for this image ( @steveiliop56 It feels to me like this doesn't need to be implemented in the Just my 2 cents, and how we're achieving it. Hope that helps! |
I mean drupal is essentially a webserver serving php, from what I see it's using apache or fpm so the entry point should be fairly easy to change. @mstenta I didn't understand this:
What do you mean downstream derivative image? |
I mean creating your own For farmOS, we create a |
That's correct. And it's exactly what we do in our downstream image. So I think the question is whether or not this "official upstream" image ( That's probably more a question for the maintainers of this project. But I can see the argument for keeping this simple and letting downstream users implement it however they want in their own images (like we do). |
If the entrypoint is all you need, you don't even need to create another image, you can just mount the entrypoint to the base image. ex:
|
Good point @LaurentGoderre! Apart from the entrypoint, I think the only other piece that's missing from the current
The entrypoint needs to copy files from the "official" Drupal build to the bind-mounted volume. But if |
Wouldn't work, from the moment the container starts the data directory is gone. The only solution I can think of is to mount only a /data directory and make the entry point copy the data from the var directory if /data is empty then simply create a symbolink link but that's again harder than it should be. |
How are you mounting your data? Are you doing it the way shown in the documentation in the Volumes section? |
The documentation itself points out the issue that @steveiliop56 is trying to solve:
This workaround works, but I think @steveiliop56 is suggesting the possibility of building a solution that would not require the workaround. |
Exactly, I don't see the reason why this design choice was selected. |
To be very specific, the reason that an empty For example, Drupal expects there to be a |
To add to this I am a contributor/maintainer at a project called runtipi, it's basically a self hosted app manager like casa os, umbrel etc. you probably have seen it. The problem here is that when adding apps to these kind of appstores having to use hacks to make the app works makes it a lot harder to ship something that just works. |
I think this is more an issue with the design choices of Drupal itself... which were made before Docker (and its expectation of an empty data volume) were created. So it is not the fault of this So there is an opportunity to improve the "default" experience of Personally, I don't find the Drupal codebase that is included in this image useful at all, because most Drupal deployments are built and managed with Composer these days (or should be as best practice). So I think in most cases you will want your own derivative image that runs |
I believe for most of the users self hosting Drupal, the bind volume is the simple thing they expect. |
@steveiliop56 Are you willing to make a pull request to demonstrate the solution you would like to see? As an open source maintainer myself I can say that it will be a lot more likely to happen if you help with the effort. And if it doesn't get in, at least you have the script you need for your downstream derivative image. :-) |
I definitely could open a pull request but there are a billion docker images and a lot of tags to change. It would change how the Drupal image works but I think it's worth a try. I will open a pull request as soon as I can (in a week or so), I will ping you to ask for your feedback @mstenta and @LaurentGoderre |
Indeed, and the documentation would also need to be updated, which is in a separate repo: https://github.com/docker-library/docs/tree/master/drupal |
I dont see why you would ever need two copies of the code base to get you application to work. That doesnt sound like a "bad design choice of Drupal's dockerfile", but rather a bad design of the app, imho. |
I don't think you understood the issue @kjostling. We don't need 2 copies of the data, we just need a bind volume. Drupal stores the data in the www directory which if you bind a volume into it, it will get replaced with basically an empty directory. The correct way to implement this would be to check if the directory is empty and if it is fill it with Drupal data else serve whatever the contents are. |
If by "bad design of the app" you mean "the app (Drupal) was not designed with Docker data volumes in mind", that's true. Drupal is more than 10 years older than Docker, and many of the "good design" patterns that Docker advocates were not standard practice when Drupal was designed. And making major changes to Drupal's core design pattern now is very difficult (due to community momentum, rules around breaking changes, etc). And so, "it's not our fault but it is our problem" that we need to work around in order to use Drupal in Docker. |
Ah, you'd like a "Wordpress version" of this image? I believe that will break alot of current usages of this image since recreation of a container won't reinstall the app-files. That's what I expect should happen when I recreate a container from an image. Volumes are indentended for data that should be persisted after recreation, ie, sites/default/files (for drupal). Im not sure about mounts since I havent used that before. Looks alot similar though. I do believe the Drupal 8 branch is 2 years younger than docker and it use composer as you pointed out earlier. Deployment should make the necessary "composer require/install" statements to set things up as the site in question wants it to be. Hovever in a usecase where users should be able to "on-click-install" drupal and change the code in the GUI I guess this is a suboptimal image. |
Drupal is really cool but the docker image has an issue where it makes it really annoying to host using docker images, bind volumes. For example a lot of us just create a docker compose with bind volumes to our data and start the app but due to the (bad) design choice of Drupal's dockerfile the volume location has already data which are getting replaced by docker. The solution is as simple as storing the data on a template location and copy them just before the web server starts. I would really like to see this implemented as it would make self hosting Drupal with docker extremely easy.
The text was updated successfully, but these errors were encountered: