Reputation: 55
I'm not able to build my image. Below is the line that I feel as the challenge. Please have a look and suggest me if I have done anything wrong. I'm trying to copy a zip file that is present in the current folder as the Dockerfile and docker-compose file. I don't have a .dockerignore file also. I'm declaring the file name as ENV and passing that value in docker-compose file.
COPY ${FILE_NAME}.zip /app/
My docker-compose file is like this.
version: '3.7'
services:
tws:
build:
context: .
dockerfile: Dockerfile
ports:
- "8085:8085"
environment:
- FILE_NAME=xxxxx
Below is the error that come during docker-compose up
ERROR: Service 'yyy' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder467027701/.zip: no such file or directory
EDIT: It is working fine if I provide the actual name instead of ENV in the Dockerfile
Upvotes: 0
Views: 240
Reputation: 131526
I think that what you need is a build argument because you perform the COPY
task at the build time and not at the container start time.
Remove that part :
environment:
- FILE_NAME=xxxxx
And update your compose such as :
build:
args:
- FILE_NAME=xxxxx
And declare the ARG
in the Dockerfile :
FROM ...
ARG FILE_NAME
...
COPY ${FILE_NAME}.zip /app/
Upvotes: 1