简体   繁体   中英

Docker compose unable to find file in ADD path

I am using the following docker compose:

dns_to_redis:
  build: 
   context: ./DNS_to_redis/
  image: dns_to_redis
  depends_on:
     - redis
  environment:
    - REDIS_HOST=redis
    - REDIS_PORT=6379
  networks:
   sensor:
     ipv4_address: 172.24.1.4

to build and run an image. Inside the Dockerfile I use the following ADD:

ADD home/new_prototypes/dns_to_redis/dns_redis.R /home/

However, when I run sudo docker-compose up , I get the following error:

ERROR: Service 'dns_to_redis' failed to build: ADD failed: file not found in build context or excluded by .dockerignore: stat home/new_prototypes/dns_to_redis/dns_redis.R: file does not exist

The file is located in /home/new_prototypes/dns_to_redis , I am thinking that this is somehow the problem, but I can't modify it in any way to make it work.

How can I run this from docker compose?

Thank you.

As stated in the error message:

file not found in build context

The build context is a copy of the path you set for dns_to_redis.build.context .

Your file needs to be in the ./DNS_to_redis/ directory. Note that it is generally preferred to use COPY instead of ADD .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM