Skip to content
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

Please don't use ports in docker-compose #1

Closed
rfay opened this issue Jan 27, 2024 · 1 comment
Closed

Please don't use ports in docker-compose #1

rfay opened this issue Jan 27, 2024 · 1 comment

Comments

@rfay
Copy link

rfay commented Jan 27, 2024

Congratulations on this add-on! People have asked for this periodically for years.

You use ports in each of the stanzas of the docker-compose.

This means that this add-on can only be used in one running project.

Instead, use expose, and HTTP_EXPOSE and HTTPS_EXPOSE environment variables to accomplish what you want.

You can look at many other add-ons to see how this is done, or docs, see https://ddev.readthedocs.io/en/latest/users/extend/custom-compose-files/#docker-composeyaml-examples

@kevinquillen
Copy link
Owner

When I do that, I get '404 not found' on the first service and "Bad Gateway" on the second:

#ddev-generated
services:
  meilisearch:
    container_name: ddev-${DDEV_SITENAME}-meilisearch
    hostname: ${DDEV_SITENAME}-meilisearch
    image: getmeili/meilisearch:v1.6
    networks: [default, ddev_default]
    restart: "on-failure"
    environment:
      - MEILI_MASTER_KEY=${MEILI_MASTER_KEY:-ddev}
      - HTTP_EXPOSE=7700:7700
    expose:
      - 7700
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      - "meili_data:/meili_data"
      - ".:/mnt/ddev_config"
  # This links the Meilisearch service to the web service defined in the main
  # docker-compose.yml, allowing applications running inside the web container to
  # access the Meilisearch service at http://meilisearch:7700
  web:
    links:
      - meilisearch:meilisearch
  meilisearch_admin:
    container_name: ddev-${DDEV_SITENAME}-meilisearch-admin
    image: riccoxie/meilisearch-ui:latest
    restart: always
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    expose:
      - "8100"
    environment:
      - VIRTUAL_HOST=meilisearch.$DDEV_HOSTNAME
      - HTTP_EXPOSE=8100:24900
    external_links:
      - "ddev-router:${DDEV_SITENAME}.${DDEV_TLD}"
volumes:
  meili_data:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants