简体   繁体   English

Docker compose 无法在 ADD 路径中找到文件

[英]Docker compose unable to find file in ADD path

I am using the following docker compose:我正在使用以下 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:在 Dockerfile 中,我使用以下 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:但是,当我运行sudo docker-compose up ,出现以下错误:

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.该文件位于/home/new_prototypes/dns_to_redis ,我认为这在某种程度上是问题所在,但我无法以任何方式对其进行修改以使其正常工作。

How can I run this from docker compose?如何从 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 . 构建上下文是您为dns_to_redis.build.context设置的路径的副本。

Your file needs to be in the ./DNS_to_redis/ directory.您的文件需要位于./DNS_to_redis/目录中。 Note that it is generally preferred to use COPY instead of ADD .请注意, 通常首选使用COPY而不是ADD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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