简体   繁体   中英

How to view docker compose logs while using dev container on vscode

I am running dev containers on my project that utilizes docker-compose for multiple containers.
My issue is that I cannot view my docker-compose logs. I am not sure how to access it.

Inside the folder .devcontainer I have two files:

  1. 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"] }
  2. 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"

This is the main docker-compose.yml inside the project folder.

    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"

如果您打开终端并在与 docker-compose 文件相同的位置运行docker-compose up ,您应该会看到您的日志

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM