Feel Physics
Feel Physics

Reputation: 2783

cannot ADD file in current directory or in the directory with full path

Current Directory

I cannot ADD file in current directory.

$ ls
Dockerfile      id_rsa.pub
$ docker build result:
Step 15 : ADD id_rsa.pub /home/ubuntu/.ssh
stat /mnt/sda1/var/lib/docker/aufs/mnt/3c26803340b5ac907bcf6a32dd2c45da9ca98
ee2e4106f9a57a45d244619092b/home/ubuntu/.ssh/id_rsa.pub: not a directory

Full Path

I cannot ADD file in the directory with full path.

$ ls /Users/weed/.ssh
config      id_rsa.pub      id_rsa      known_hosts
$ docker build result:
Step 15 : ADD /Users/weed/.ssh/id_rsa.pub /home/ubuntu/.ssh
Users/weed/.ssh/id_rsa.pub: no such file or directory

Upvotes: 0

Views: 1597

Answers (2)

Peter Lyons
Peter Lyons

Reputation: 146014

Try with a trailing slash in your ADD line

ADD /Users/weed/.ssh/id_rsa.pub /home/ubuntu/.ssh/

From the docs:

If <dest> does not end with a trailing slash, it will be considered a regular file and the contents of <src> will be written at <dest>.

So I think /home/ubuntu/.ssh is already a directory in the container and the ADD command is trying to overwrite it as a file instead of create a new file within the directory.

Upvotes: 3

Will Angley
Will Angley

Reputation: 1394

The files you're trying to add look like SSH public keys. Could you check the permissions on id_rsa.pub , and the permissions on ~/.ssh , with ls -la ? It's likely that Docker's build process doesn't have access to either of them.

Upvotes: 0

Related Questions