我在我的项目上运行开发容器,该docker-compose
容器用于多个容器。
我的问题是我无法查看我的 docker-compose 日志。我不确定如何访问它。
在文件夹.devcontainer
中,我有两个文件:
devcontainer.json
:{ "name": "TrendR", "dockerComposeFile": [ "../docker-compose.yml", "docker-compose.yml" ], "service": "api", "workspaceFolder": "/workspace", "settings": { "python.pythonPath": "/usr/local/bin/python", "python.linting.enabled": true, "python.linting.pylintEnabled": true, }, "extensions": ["ms-python.python","ms-azuretools.vscode-docker"] }
docker-compose.yml
:version: '3.8' services: api: volumes: - .:/workspace:cached - /var/run/docker.sock:/var/run/docker.sock command: /bin/sh -c "while sleep 1000; do :; done"
这是项目文件夹中的主要 docker-compose.yml。
version: "3.8"
services:
db:
container_name: db
image: postgres:13
ports:
- "5433:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- /var/lib/postgresql/data
api:
build:
context: ./api/
dockerfile: Dockerfile
volumes:
- ./api/app:/app/app
ports:
- "1000:80"
depends_on:
- db
env_file:
- .env
command: ["/start-reload.sh"]
labels:
- "traefik.enable=true"
- "traefik.http.routers.${API_SUBDOMAIN}.rule=Host(`${API_SUBDOMAIN}.${DOMAIN}`)"
frontend:
build:
context: ./frontend/
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- /app/node_modules
- ./frontend:/app
environment:
- NODE_ENV=development
stdin_open: true
links:
- api
labels:
- "traefik.enable=true"
- "traefik.http.routers.${CLIENT_SUBDOMAIN}.rule=Host(`${CLIENT_SUBDOMAIN}.${DOMAIN}`)"
redis:
container_name: trendr_redis
image: "redis:alpine"
ports:
- "6379:6379"
traefik:
image: traefik:v2.4
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "$PWD/traefik/traefik.dev.toml:/etc/traefik/traefik.toml"