Home > OS >  Eliminate attribute from inherited container?
Eliminate attribute from inherited container?

Time:08-27

So, I have two containers. One of them (named celery) should inherit everything from the other one, but it should have no port (I don't want it to be exposed). The problem is that the first one has a port set already, and the second one will inherit it.

How can I make the second container inherit everything from the first one, but have no ports expoesd?

Thanks.

django: &django
    container_name: ${COMPOSE_PROJECT_NAME}_django.dev
    ports:
      - "8000:8000"

celery: 
    <<: *django
    container_name: ${COMPOSE_PROJECT_NAME}_celery.dev
    command: "python -m celery -A app worker"

CodePudding user response:

Unsetting the overridden ports in celery should work, i.e. set to empty array.

django: &django
    container_name: ${COMPOSE_PROJECT_NAME}_django.dev
    ports:
      - "8000:8000"

celery: 
    <<: *django
    container_name: ${COMPOSE_PROJECT_NAME}_celery.dev
    command: "python -m celery -A app worker"
    ports: []
  • Related