3

I have wrote a Dockerfile to create a new node.js container with given code:

FROM node:latest
RUN mkdir -p //usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
EXPOSE 8080
EXPOSE 5858
CMD [ "npm", "start" ]

nothing complicated. But now I add a symbolic link to the folder, which should added to container. But if I try to run the container I get a error message that a folder is not found. It is same I added as symbolic link.

Is there a possibility to keep link and tell docker to follow link and copy files to docker container?

Vini.g.fer
  • 10,633
  • 14
  • 51
  • 78
CordlessWool
  • 988
  • 2
  • 13
  • 29

1 Answers1

1

That is not possible and will not be implemented. Please have a look at the discussion on github issue #1676:

We do not allow this because it's not repeatable. A symlink on your machine is the not the same as my machine and the same Dockerfile would produce two different results. Also having symlinks to /etc/paasswd would cause issues because it would link the host files and not your local files.

Camilo Silva
  • 6,674
  • 4
  • 33
  • 52
  • 1
    Thanks for fast response. Do you know if there is a other way then symbolic link to include files, that is 'accepted'/read by docker? – CordlessWool Jul 27 '16 at 23:04
  • You might create a simple script that copies temporally the files from your symlinks, build the docker image and then remove them – Camilo Silva Jul 27 '16 at 23:32
  • 2
    What's sad is that is that a Dockerfile that requires that a separate script be run before building is also "not repeatable" in precisely the same way, so this limitation of Docker really achieves nothing. The thing that guarantees repeatability is the Git repository, not the Dockerfile. – Will Vousden Jul 10 '19 at 06:09