新代码更改存在于实时容器中,但未反映在浏览器中

时间:2019-09-25 12:38:19

标签: docker docker-compose dockerfile apache-superset

我正在将Docker与开源BI工具Apache Superset一起使用。我在CountryMap目录中添加了一个新文件,特别是.geojson文件。现在,当我尝试使用docker-compose up --build进行构建或在前端进行更改时,Docker尚未完全更新,并且在尝试运行查询时出现文件未找到错误。当我通过docker exec -it container_id bash查看容器内部时,新文件就在那里。

Dockerfile:

FROM python:3.6-jessie

RUN useradd --user-group --create-home --no-log-init --shell /bin/bash superset

# Configure environment
ENV LANG=C.UTF-8 \
    LC_ALL=C.UTF-8

RUN apt-get update -y

# Install dependencies to fix `curl https support error` and `elaying package configuration warning`
RUN apt-get install -y apt-transport-https apt-utils

# Install superset dependencies
# https://superset.incubator.apache.org/installation.html#os-dependencies
RUN apt-get install -y build-essential libssl-dev \
    libffi-dev python3-dev libsasl2-dev libldap2-dev libxi-dev

# Install extra useful tool for development
RUN apt-get install -y vim less postgresql-client redis-tools

# Install nodejs for custom build
# https://superset.incubator.apache.org/installation.html#making-your-own-build
# https://nodejs.org/en/download/package-manager/
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
    && apt-get install -y nodejs

WORKDIR /home/superset

COPY requirements.txt .
COPY requirements-dev.txt .
COPY contrib/docker/requirements-extra.txt .

RUN pip install --upgrade setuptools pip \
    && pip install -r requirements.txt -r requirements-dev.txt -r requirements-extra.txt \
    && rm -rf /root/.cache/pip

RUN pip install gevent

COPY --chown=superset:superset superset superset

ENV PATH=/home/superset/superset/bin:$PATH \
    PYTHONPATH=/home/superset/superset/:$PYTHONPATH

USER superset

RUN cd superset/assets \
    && npm ci \
    && npm run build \
    && rm -rf node_modules

COPY contrib/docker/docker-init.sh .
COPY contrib/docker/docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

HEALTHCHECK CMD ["curl", "-f", "http://localhost:8088/health"]

EXPOSE 8088

docker-compose.yml:

version: '2'
services:
  redis:
    image: redis:3.2
    restart: unless-stopped
    ports:
      - "127.0.0.1:6379:6379"
    volumes:
      - redis:/data

  postgres:
    image: postgres:10
    restart: unless-stopped
    environment:
      POSTGRES_DB: superset
      POSTGRES_PASSWORD: superset
      POSTGRES_USER: superset
    ports:
      - "127.0.0.1:5432:5432"
    volumes:
      - postgres:/var/lib/postgresql/data

  superset:
    build:
      context: ../../
      dockerfile: contrib/docker/Dockerfile
    restart: unless-stopped
    environment:
      POSTGRES_DB: superset
      POSTGRES_USER: superset
      POSTGRES_PASSWORD: superset
      POSTGRES_HOST: postgres
      POSTGRES_PORT: 5432
      REDIS_HOST: redis
      REDIS_PORT: 6379
      # If using production, comment development volume below
      #SUPERSET_ENV: production
      SUPERSET_ENV: development
#      PYTHONUNBUFFERED: 1
    user: root:root
    ports:
      - 8088:8088
    depends_on:
      - postgres
      - redis
    volumes:
      # this is needed to communicate with the postgres and redis services
      - ./superset_config.py:/home/superset/superset/superset_config.py
      # this is needed for development, remove with SUPERSET_ENV=production
      - ../../superset:/home/superset/superset

volumes:
  postgres:
    external: false
  redis:
    external: false

为什么没有找到错误?

2 个答案:

答案 0 :(得分:0)

尝试在volumes:中使用绝对路径

volumes:
  - /home/me/my_project/superset_config.py:/home/superset/superset/superset_config.py
  - /home/me/my_project/superset:/home/superset/superset

答案 1 :(得分:0)

这是因为docker-compose正在使用缓存。如果dockerfiledocker-compose.yml的位置未更改,则不会重新创建容器映像。为了避免这种情况,您应该使用以下标志:

 --force-recreate
  

-force-recreate

     

重新创建容器,即使它们的配置和映像没有   改变了。

出于开发目的,我也喜欢使用以下开关:

  

-V,--renew-anon-volumes

     

重新创建匿名卷,而不是从以前的容器中检索数据。