Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker文件更新卷_Docker_Elixir - Fatal编程技术网

Docker文件更新卷

Docker文件更新卷,docker,elixir,Docker,Elixir,您好,我有一个elixir项目,但我怀疑在本地更新文件时如何创建链接更新docker, 因此,您不必每次更新内容时都使用docker compose 我的docker文件: FROM elixir:alpine RUN apk add --update --no-cache curl py-pip RUN apk add --no-cache build-base git WORKDIR /app RUN mix local.

您好,我有一个elixir项目,但我怀疑在本地更新文件时如何创建链接更新docker, 因此,您不必每次更新内容时都使用docker compose

我的docker文件:

    FROM elixir:alpine
    
    RUN apk add --update --no-cache curl py-pip
    RUN apk add --no-cache build-base git
    
    WORKDIR /app
    
    RUN mix local.hex --force && \
            mix local.rebar --force
    
    COPY mix.exs mix.lock ./
    COPY config config
    
    RUN mix do deps.get, deps.compile
    
    COPY priv priv
    COPY lib lib
    
    COPY numbers.csv numbers.csv
    
    COPY docker-entrypoint.sh docker-entrypoint.sh
    
    EXPOSE 4000

docker-compose:

version: "3.7"
services:
  app:
      restart: on-failure
      build: .
      command: /bin/sh docker-entrypoint.sh
      ports: 
        - "4000:4000"
      depends_on: 
        - postgres-db 
      links:
        - postgres-db
      env_file:
        - .env
  postgres-db:
      image: "postgres:12"
      restart: always
      container_name: "postgres-db"
      environment: 
        POSTGRES_PASSWORD: ${DB_PASS}
        POSTGRES_USER: ${DB_USER}
        POSTGRES_DB: ${DB_NAME}
      ports: 
        - "5432:5432"
文件夹结构:


您应该有另一个docker compose文件,名为
docker compose.override.yml
,这是本地开发的设置。在该文件中,您可以使用
volumes
获取docker容器中反映的本地文件更新(在docker容器运行时):

它看起来像这样(查看
部分):


您好,您能帮助我如何运行docker-compose.override.yml吗?因为我有两个docker compose,我不知道如何在docker上运行它。是的,没问题。只需像平常一样使用docker compose。它更喜欢使用覆盖文件。
version: "3.8"
services:
  db:
    image: postgres:13.0
    env_file:
      - ./docker/dev.env
    restart: always
    ports:
      - "5432:5432"
    volumes:
      - db-data:/var/lib/postgresql/data

  spiritpay:
    image: spiritpay:local
    build:
      context: .
      dockerfile: ./Dockerfile
    depends_on:
      - db
    stdin_open: true
    tty: true
    env_file:
      - ./docker/dev.env
    ports:
      - "4000:4000"
      - "4002:4002"
    volumes:
      - /opt/spiritpay/assets/node_modules
      - ./assets:/opt/spiritpay/assets
      - ./config:/opt/spiritpay/config:ro
      - ./lib:/opt/spiritpay/lib:ro
      - ./priv:/opt/spiritpay/priv
      - ./test:/opt/spiritpay/test:ro
      - ./mix.exs:/opt/spiritpay/mix.exs:ro
      - ./mix.lock:/opt/spiritpay/mix.lock:ro

volumes:
  db-data: