1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | version: "2" services: drupal: image: drupal ports: - "8080:80" volumes: - drupal-modules:/var/www/html/modules - drupal-profiles:/var/www/html/profiles - drupal-sites:/var/www/html/sites - drupal-themes:/var/www/html/themes postgres: image: postgres environment: - POSTGRES_PASSWORD=1234 volumes: drupal-modules: drupal-profiles: drupal-sites: drupal-themes: |
When we are done, we use docker-compose down -v to remove everything.
Note that the service name is implicitly also the hostname of the service. For instance, when we try to connect to postgres database inside the network from one of the container (for example, our drupal service), the hostname is can be put as postgres.
Another example of docker-compose:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | version: "2" services: proxy: build: context: . dockerfile: nginx.Dockerfile image: nginx-custom ports: - "80:80" web: image: httpd volumes: - ./html:/usr/local/apache2/htdocs/ |
- use COPY in Dockerfile
- use volumes in docker-compose.yml.
No comments:
Post a Comment