我正在使用docker compose来创建图像。运行时,我的docker镜像抛出一个异常,说找不到server.py.任何帮助将不胜感激。
下面的是我的docker-compose文件的片段
python:
build: .
image: python:3.6
environment:
DEBUG: 'true'
PORT: '8080'
volumes:
- ./:/web/server
links:
- postgres
ports:
- "8080:8080"
command: ["python", "server.py"]
postgres:
image: onjin/alpine-postgres:9.5
restart: unless-stopped
ports:
- "5442:5432"
environment:
LC_ALL: C.UTF-8
POSTGRES_USER: ahmad
POSTGRES_PASSWORD: ahmad
POSTGRES_DB: ahmad
服务:
ENV DIR /web/server
ADD . ${DIR}
WORKDIR ${DIR}
Dockerfile片段
${__changeCase(${__P(env)},LOWER,)}
答案 0 :(得分:0)
试试这个
搬运工-compose.yml
version: '3'
services:
python:
build: ./folder_with_docker_file
command: ["python", "/usr/local/lib/python3.6/http/server.py"]
volumes:
- ./:/web/server
links:
- postgres
ports:
- "8080:8080"
environment:
DEBUG: 'true'
PORT: '8080'
postgres:
image: onjin/alpine-postgres:9.5
restart: unless-stopped
ports:
- "5442:5432"
environment:
LC_ALL: C.UTF-8
POSTGRES_USER: ahmad
POSTGRES_PASSWORD: ahmad
POSTGRES_DB: ahmad
Dockerfile
FROM python:3.6
ENV DIR /web/server
ADD . ${DIR}
WORKDIR ${DIR}
结构:
├───stack
│ │ docker-compose.yml
│ │
│ └───test
│ dockerfile
堆栈和测试是文件夹