I managed to have some containers with this config in order to run a Drupal app:
version: '3.1'
services:
drupal:
depends_on:
- postgres
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:80
volumes:
- type: bind
source: ./workspace
target: /opt/workspace
networks:
- beayoga
restart: always
postgres:
image: postgres:13.2
environment:
POSTGRES_PASSWORD: example
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- beayoga
restart: always
pgadmin:
depends_on:
- postgres
image: dpage/pgadmin4
ports:
- 443:443
- 8081:80
environment:
- PGADMIN_DEFAULT_EMAIL=foo@bar.com
- PGADMIN_DEFAULT_PASSWORD=foobar
networks:
- beayoga
volumes:
pg_data:
networks:
beayoga:
It is working well, when changing a file from my host I can see the changes in my container (using the interactive terminal) and when changing a file from the my container I can see the changes in my host.
When I want to see the changes, I have to run this command:
./vendor/bin/drush cc
When I run it from my container, I get this:
www-data@5c6c061c1519:/opt/workspace$ ./vendor/bin/drush cc
Choose a cache to clear [all]:
[0] Cancel
[1] drush
[2] theme-registry
[3] router
[4] css-js
[5] render
[6] plugin
[7] bin
[8] views
Then I can choose [5]
to see the changes in my webpage.
I want to run this same command from my host, so that in the future, I won't need to connect to the container with the interactive terminal.
When I run the exact same command, from my host, I get this:
➜ workspace git:(dev) ✗ ./vendor/bin/drush cc
Choose a cache to clear [all]:
[0] Cancel
[1] drush
I only have those two options that are displayed, and I cannot choose [5] render
Does somebody know what is happening and how can I get the whole list of choices ?
What I've tried so far:
I see some answers on google suggesting that it could be something related to the database. So I installed psql in my host and added the name of the postgres container in my /etc/hosts
file (using the ip given when running docker inspect
), but I still had the same 2 items showing in the list with no more...
Edit
To answer @Patrick W comment:
Render and status on remote (container)
www-data@5c6c061c1519:/opt/workspace$ ./vendor/bin/drush cc render
[success] 'render' cache was cleared.
www-data@5c6c061c1519:/opt/workspace$ ./vendor/bin/drush status
Drupal version : 9.1.4
Site URI : http://default
DB driver : pgsql
DB hostname : postgres
DB port : 5432
DB username : postgres
DB name : postgres_development
Database : Connected
Drupal bootstrap : Successful
Default theme : my_custom_theme
Admin theme : seven
PHP binary : /usr/local/bin/php
PHP config :
PHP OS : Linux
Drush script : /opt/workspace/vendor/drush/drush/drush
Drush version : 10.4.0
Drush temp : /tmp
Drush configs : /opt/workspace/vendor/drush/drush/drush.yml
Install profile : standard
Drupal root : /opt/workspace/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp
Render and status on host
➜ workspace git:(dev) ✗ ./vendor/bin/drush cc render
In CacheCommands.php line 261:
'render' cache requires a working Drupal site to operate on. Use the --root and --uri options, or a site @alias, or cd to a directory containing a Drupal settings.php file.
➜ workspace git:(dev) ✗ ./vendor/bin/drush status
Drupal version : 9.1.4
Site URI : http://default
DB driver : pgsql
DB hostname : postgres
DB port : 5432
DB username : postgres
DB name : postgres_development
PHP binary : /usr/bin/php
PHP config : /etc/php.ini
PHP OS : Linux
Drush script : /home/david/Desktop/beayoga/workspace/vendor/drush/drush/drush
Drush version : 10.4.0
Drush temp : /tmp
Drush configs : /home/david/Desktop/beayoga/workspace/vendor/drush/drush/drush.yml
Drupal root : /home/david/Desktop/beayoga/workspace/web
Site path : sites/default
However I'm in the exact same directory, since they are bound together...
Do you know how Drupal gets to know if it is installed ? Maybe it try to look on another folder which isn't on the host ?