AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 964633
Accepted
ivanleoncz
ivanleoncz
Asked: 2019-04-26 11:30:47 +0800 CST2019-04-26 11:30:47 +0800 CST 2019-04-26 11:30:47 +0800 CST

docker-compose build --no-cache 不工作

  • 772

我对其中一项服务的 Dockerfile 进行了一些更新,但这些更改在运行时没有反映出来docker-compose build,甚至在使用--no-cache选项时也没有反映出来。

我在运行之前添加了两个两个参数pip install -f requirements.txt,但它们不会在任何时候执行:它直接进入需求步骤。

$ docker-compose build --no-cache
mongo uses an image, skipping
postgres uses an image, skipping
elasticsearch uses an image, skipping
Building nucleo
Step 1/9 : FROM python:3.6
 ---> 2bb3204ab1d1
Step 2/9 : COPY core/ /container_core/
 ---> cc1eadcb80a3
Step 3/9 : WORKDIR /container_core
 ---> Running in e8afa25b9c9a
Removing intermediate container e8afa25b9c9a
 ---> f9b928dee6f5
Step 4/9 : RUN pip install -r requirements.txt
 ---> Running in 84f474edb526
^CERROR: Aborting.

码头工人-compose.yml

services:
    mongo:
        image: "mongo:4.0.5"
        container_name: compose_mongo
        restart: always
        environment:
            - MONGO_INITDB_ROOT_USERNAME=mongo
            - MONGO_INITDB_ROOT_PASSWORD=mongopass
        ports:
            - "27017:27017"
    core:
        build:
            context: /home/ivanleoncz/git/core
            dockerfile: Dockerfile
        container_name: compose_core
        depends_on:
            - mongo
        env_file:
            - .env
        ports:
            - "8000:8000"

Dockerfile

FROM python:3.6
COPY core/ /container_core/
WORKDIR /container_core
# must run before requirements
RUN pip install --upgrade pip
RUN pip install urllib3=1.20
# then, run the requirements
RUN pip install -r requirements.txt
CMD ["python3", "manage.py", "makemigrations", "app1"]
CMD ["python3", "manage.py", "makemigrations", "app2"]
CMD ["python3", "manage.py", "makemigrations", "app3"]
CMD ["python3", "manage.py", "migrate"]
CMD ["python3", "manage.py", "runserver"]

我正在使用 docker-compose 1.21.2 和 Ubuntu 18.04.2。

我如何保证docker-compose没有使用旧版本的 Dockerfile,即使我描述的是我想要执行构建,没有任何缓存(--no-cache)?

docker
  • 1 1 个回答
  • 7344 Views

1 个回答

  • Voted
  1. Best Answer
    ivanleoncz
    2019-04-26T13:24:48+08:002019-04-26T13:24:48+08:00

    我从与docker-compose.yaml的标签上docker-compose build --no-cache定义的目录不同的目录运行。context

    core:
        build:
            context: /home/ivanleoncz/git/core
            dockerfile: Dockerfile
    

    在这个不同的目录中,我正在更新我的 Dockerfile,而在上下文目录中,我有一个过时的 Dockerfile。

    由于定义的上下文,/home/ivanleoncz/git/core/Dockerfile在此过程中考虑了docker-compose build --no-cache,而不是我当前目录中的 Dockerfile。

    • 2

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve