Set the current directory to that containing docker-compose.yml: vagrant sshĬd /opt/provision/docker/compose/example/ Mysql has the hostname "mysql", Redis is "redis", etc., and the ports are as defined by the containers and mapped in docker-compose.yml. Note the simple networking provided by Docker Compose. $conf = 'sites/all/modules/contrib/redis/' sudo rm -rf code/example/drupal/sites/default/files & sudo ln -s /var/www_files code/example/drupal/sites/default/files On a Mac, you should symlink the files directory to a location not shared to your host to avoid performance issues trying to sync files generated by Drupal. To test, download a Drupal 7 codebase with some contrib to use Redis and Solr: drush -y dl -destination=code/example -drupal-project-rename drupalĭrush -y dl -destination=code/example/drupal/sites/all/modules/contrib redis search_api search_api_solr entity views ctools Vagrant rsync-auto > ~/Library/Logs/vagrant-rsync-auto.log & Add Drupal To get code and Docker files on the virtual machine, we are sharing 2 directories: # Project/site files. Rsync_args: Ĭonfig.vm.synced_folder '.', '/vagrant', disabled: trueĬonfig.vm.synced_folder './code/', '/opt/code', optsĬonfig.vm.synced_folder './provision/', '/opt/provision', opts hostname = 'v'Ĭonfig.vm.box = 'tbfisher/ubuntu1504docker' There seem to be several still-evolving options that wrap VirtualBox with some sort of UI, but they don't seem too stable or performant yet, so I use Vagrant to build a VM, using a base box with Docker Compose already installed, and fast rsync shared folders. If on a Mac, you will need a virtual machine. In order to use this, we need Docker Compose. To get code on the webserver container, in the Docker Compose file above, we specify a volume: volumes: conf/ssh/authorized_keys /root/.ssh/authorized_keys FROM tbfisher/drupal-nginx:php-5.5.xĬhown -R www-data:www-data /var/www_filesĬOPY. This extends an existing image with the Drupal Search API Solr module required configuration.įor the webserver, I'm using an Nginx+PHP-FPM+Drush image of my own, extended to create files directories and copy my public key to be able to run drush commands. conf/solr/search_api/4.x /opt/solr/example/solr/collection1/conf For example, the solr container contains a build key that is a relative path to a directory containing the Dockerfile: FROM guywithnose/solr:4.10.2ĬOPY. If an existing image does not exactly suit your needs, you can easily extend. So, from the web container, you can connect to the mysql container using mysql -host=mysql -user=root -port=3306 -password=rootpasswd. In this case the MySQL and Redis containers are examples of official images.Ĭontainers are linked by adding a list links. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.įor example, here is a Docker Compose configuration I use for a Drupal 7 site with Redis and Solr: mysql:Įach top level key is a named container, and each container declares either an image or a build. Docker manages both memory and storage resources across containers and provides a good method of packaging and managing filesystem images, making initial startup much faster than Vagrant and subsequent startups nearly instantaneous.ĭocker Compose is a Docker wrapper that allows you to easily define and manage sets of containers for a project.Ĭompose is a tool for defining and running multi-container applications with Docker. Instead of highly isolated virtual machines defined in Vagrant and managed by a hypervisor, Docker shares the host OS kernel with virtualized environment containers. This means that virtualized processes are essentially native, do not require the overhead of virtual machines and still provide a high level of isolation from the host OS. Multi-machine setups or many independent services can complicate or make impossible a Vagrant-based approach.Įnter Docker. And overhead is still an issue - provisioning is slow and single machine environments take a lot of disk space and require a significant portion of the memory allotted in production. Developers, however, typically don't have the skills or the inclination to get their hands dirty with Vagrantfile's or provisioner scripts. If you work in a limited number of environments that happen to be provisioned in a compatible way, you would have a framework to distribute environments to developers. Vagrant made virtualized environments configurable and portable and made sharing environments popular.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |