mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

nginx section can't bring running docker down #435

Closed giffiecode closed 9 months ago

giffiecode commented 9 months ago
Yuechen.Pei.23@lambda-server:~/flask-on-docker$ docker-compose -f docker-compose.prod.yml down -v
/home/Yuechen.Pei.23/.local/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
  from cryptography.hazmat.backends import default_backend
ERROR: The Compose file './docker-compose.prod.yml' is invalid because:
'nginx' does not match any of the regexes: '^x-'

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

I got this error when running vim docker-compose.prod.yml in the nginx section. Still doesn't work after changing the version to 3.3 in the prod.yml file

mikeizbicki commented 9 months ago

I googled your error message and found this stackoverflow answer as the top result and I suspect their solution will solve your problem. Without seeing your docker-compose.prod.yml file, however, I can't say for sure that this is the same root cause of the error.

giffiecode commented 9 months ago
version: '3.3'

services:
  web:
    build:
      context: ./services/web
      dockerfile: Dockerfile.prod
    command: gunicorn --bind 0.0.0.0:5000 manage:app
    expose:
      - 5000
    env_file:
      - ./.env.prod
    depends_on:
      - db
  db:
    image: postgres:13
    volumes:
      - postgres_data_prod:/var/lib/postgresql/data/
    env_file:
      - ./.env.prod.db

volumes:
  postgres_data_prod:

nginx:
  build: ./services/nginx
  ports:
    - 1337:80
  depends_on:
    - web

Thanks Mike, let me look into the stackover flow. Meanwhile this is my docker-compose.prod.yml file