By Anonymous (not verified) on
Aaaaand we got an official Drupal Docker container! (I know it's sitting there since 2015-04-29 02:45:55 lol)
In case you're wondering what are these Docker containers, they're a way of simplifying our development without actually being scared of breaking something.
Also, if you want to get in the commands faster I recommend you this cheatsheet with more or less basic commands.
Start dockerizing your environment and let's ship those templates :D
Here is my version of Drupal 8 running on Docker :)
Comments
Is it really official? Is
Is it really official? Is this something the Drupal organization has put out?
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Yes it is
As they say in their Official Repositories Documentation:
Also
I think it would be the
I think it would be the Docker official Drupal container then, rather than the Drupal official Docker container, as it's not offical by the Drupal organization, but rather by the Docker organization.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Drupal staff confirmation
I think the best way to know this is to actually get confirmation from a certified Drupal staff member :)
subscribing to follow this.
subscribing to follow this.
I missed...
I don't understand run command:
$ docker run --name some-drupal -d drupal
where could i find more info about options and possible arguments? where is defined -d option and what is means? This is a base Docker to implement a custom docker or i could use it ? how to choose drupal 7 or 8?
Sorry, if it not the place to ask this things but I really missed.
Thanks in advance.
Hi molavec,
Hi molavec,
to get all possible arguments just run 'docker run -help'.
In the example command, 'some-drupal' is the name you want to assign to your container and 'drupal' is the tag that will be pulled from repository to build the container (if you didn't pulled it from repository at the beginning with 'docker pull drupal' command).
To get the latest version (8) just use 'drupal' as tag.
To get the latest drupal 7 version use 'drupal:7'.
To get specific drupal 7 version use, for example, 'drupal:7.38'.
How to use the official container with a shared folder?
Hello,
Can anyone tell me how we use the container without erasing the content of the /var/www/html folder when sharing this folder?
docker run -d -P -v $HOME/site/drupal8:/var/www/html --name drupal8 drupal
I have tried this but, as it is a mountpoint, the content of the remote folder (/var/www/html) is replaced by the content of the host folder which is nothing ($HOME/site/drupal8).
Thank you!
This is normal behaviour -
This is normal behaviour - docker does not "merge" but replaces folder contents when mounting to an existing (container) folder.
I'm not sure what you are trying to achieve but if you really want to keep the original content, you have to use a different mount point e.g.
-v $HOME/site/drupal8:/var/www/html/my-drupal8. /var/www/html will contain all original files plus a "my-drupal8" folder.Hi paul_ck, thanks for your
Hi paul_ck, thanks for your answer. I know it is the normal behavior of mount point. However, I don't understand how it can be useful to have a docker already with Drupal installed if when we run the machine the mount point replaces the content of the drupal folder. And if we don't share the folder with our host machine we can't edit the code. Is this a docker just to test drupal maybe?
We use it in different ways
tl;dr: Mount your project directory for dev, build your own docker image for production.
We use it in different ways for different purposes:
* Quick test-drive/demo: just run the container and don't mount anything
* Development: "git clone" your Drupal 8 Project to the host system and mount everything into the container. Now you can edit code and see the changes in your browser (you will likely encounter some file permission problems but nothing one can't fix)
* Production: When development is done, we push the code to git. This triggers a CI system which checks out the updated code, builds the whole stuff and "bakes" it into a production-deployable docker image (
docker build -t my-fancy-drupal .).This image is also used for functional and integration tests.
The Dockerfile basically looks like:
Docker-unrelated note: Be very careful what you expose in production! Right now the default Drupal 8 setup is a security nightmare, e.g. you can access http://localhost/composer.lock which tells the whole world about your installed packages and their security issues.
I'd love to see a "web" or "public" directory with nothing but an index.php and some assets in it (see Symfony2 and most other PHP application from the 21st century).
Drupal-unrelated note: Be careful with credentials when using docker (https://github.com/docker-library/mariadb/issues/21)
I was able to make this work finally
I was able to make this work finally, this is how i did it:
http://www.drupalprogrammer.co.uk/2016/02/create-drupal-development-usin...
I tried with just mounting the whole drupal folder, ran into problems, so had to mount modules & themes folder seperately then worked like a charm. I also used the mysql docker container to store data. Hope this helps someone.
Nice write up!
Nice write up!
The file permission/user-mapping-in-development-problem is a bit tricky. You have to take care, that sites/default/files is writable for the container user `www-data` which does not necessarily exist on the host.
Plus, all vendor/bin commands should be executed as user www-data.
A proper way of running drupal's unit tests in a running container could be:
docker exec -it drupal su -s /bin/bash -p -c "vendor/bin/phpunit -c core" www-dataUnfortunately there is no easy way yet, I guess.
User namespaces (Docker 1.10+) might be a game changer however.
Thanks Paul_ck
I also was wondering why there is no drush or drupal console in the container..
Is it really official? can't
Is it really official? can't be true...
Underscore = official
Everything under http://hub.docker.com/_/ is considered official.
See http://stackoverflow.com/questions/27264113/whats-the-meaning-of-docker-...
You can find the repositories of these images here: https://github.com/docker-library/
More details about best practices and the review process of "official docker images" can be found here: https://github.com/docker-library/official-images#review-guidelines
My Drupal 8 on Docker
I've attached the URL to Drupal 8 on Docker
Official Drupal Docker container
check path docker run -d -P -v $HOME/site/drupal8:/var/www/html --name drupal8 drupal
maybe you 're wrong somewhere
problem with local drupal mount
The official docker container has some problems with sharing users local drupal code
problem with local drupal mount
Not if you mount your code as a volume..
You can also mount more than 1 volume, so you can mount modules, themes and profiles separately eg.
docker run -v /$HOME/work/admin-d8/modules:/var/www/html/modules -v /$HOME/work/admin-d8/themes:/var/www/html/themes -v /$HOME/work/admin-d8/profiles:/var/www/html/profiles -p 8080:80 --name mydrupal -d drupal:8.1.0
source: http://www.drupalprogrammer.co.uk/2016/02/create-drupal-development-usin...
Is this container meant for production use?
I've found this container via docker hub and was trying to set it up for production. But I got stumped by the problem that I can't find a way to persist files. I've tried using a volume
-v ./drupal-data:/var/www/htmlbut that ended up with an empty /var/www folder (which is normal).I've now later come across this thread, and looking at the comments it looks like this is an image used for drupal development. It does not look like it's meant as a production container?
If I want to publish a site based on drupal, would you recommend to:
In case it's the last point: how would I achieve that?
I've tried to build a docker
I've tried to build a docker container for production, it's Drupal 8.6 set up with composer and drush, maybe you want to try it: https://hub.docker.com/r/feikede/drupal8-docker/
Issues with volumes
@nidash and @exhuma they are currently having issues with volumes, as you can see from the GitHub issues raised.
Docker4Drupal.org
Check out this open source initiative https://github.com/Wodby/docker4drupal, it's a set of containers with the compose file you can use to spin up your local environment with Docker
thanks
thanks