第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

編寫以代碼 0 退出的容器并將其記錄為空

編寫以代碼 0 退出的容器并將其記錄為空

手掌心 2022-06-02 15:33:17
我需要用 docker 容器化一個 Django Web 項目。我將項目分為儀表板、api-server 和數據庫。當我輸入docker-compose up時,它打印api-server exited with code 0和 api-server 容器退出(0),然后我輸入docker logs api-server,它返回空,但其他容器正常。我不知道如何檢查問題。api-server目錄結構如下api-server    server/    Dockerfile    requirements.txt    start.sh    ...    ...一些compose yml內容如下dashboard:    image: nginx:latest    container_name: nginx-dashboard    volumes:      - /nginx/nginx/default:/etc/nginx/conf.d/default.conf:ro      - /nginx/dist:/var/www/html:ro    ports:      - "80:80"    depends_on:      - api-server  api-server:    build: /api-server    container_name: api-server    volumes:      - /api-server:/webapps    ports:      - "8000:8000"    depends_on:      - db  db:    image: postgres    container_name: Postgres    environment:      - POSTGRES_USER=postgres      - POSTGRES_PASSWORD=postgres      - POSTGRES_DB=postgres    ports:      - "5432:5432"api-server的一些Dockerfile內容如下FROM python:3.6ENV PYTHONUNBUFFERED 1RUN mkdir /webappsWORKDIR /webappsRUN apt-get clean && apt-get update && apt-get upgrade -y && apt-get install -y python3-pip libpq-dev apt-utilsCOPY ./requirements.txt /webapps/RUN pip3 install -r /webapps/requirements.txtCOPY . /webapps/CMD ["bash","-c","./start.sh"]start.sh 如下#!/usr/bin/env bashcd server/python manage.py runserver 0.0.0.0:8000輸入docker-compose up結果如下root@VM:/home/test/Documents/ComposeTest# docker-compose upCreating network "composetest_default" with the default driverCreating Postgres ... doneCreating api-server     ... doneCreating dashboard ... doneAttaching to Postgres, api-server, dashboardPostgres | The files belonging to this database system will be owned by user "postgres".Postgres | This user must also own the server process.......api-server exited with code 0api-server exited with code 0docker logs api-server是空的如果你們能告訴我如何檢查這個問題,我將不勝感激,最好提供解決方案。
查看完整描述

1 回答

?
桃花長相依

TA貢獻1860條經驗 獲得超8個贊

您已經api-server在構建期間復制到 Dockerfile,這應該可以正常工作,但在 Docker 組合中,它會覆蓋所有 pip 包和代碼。

    volumes:
      - /api-server:/webapps

從 Docker 組合中刪除該卷,它應該可以工作。

第二件事是設置 bash 腳本的權限。

COPY . /webapps/
RUN chmod +x ./start.sh

第三件事,您確實需要使用 bash 運行 python,因為 bash 中沒有 CMD 無法執(zhí)行的東西,那么為什么不作為 CMD 呢?

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]


查看完整回答
反對 回復 2022-06-02
  • 1 回答
  • 0 關注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號