2

In my Dockerfile I have this line:

RUN ln -s /var/www/html/some_file /var/www/html/another_file

When running docker build all the steps are executed including the creation of the symbolic link, but when I start a container using the image created and check the folder /var/www/html/ I don't see the link there. I tried searching online if this is something supported by docker and couldn't find an answer. The content of the container is already available by another container image I am using with the FROM instruction, so the file /var/www/html/some_file is not on my machine.

No Volumes are involved. This is the Dockerfile:

FROM piwik:3.2.1-apache

RUN apt update

RUN ln -s /var/www/html/some_file /var/www/html/another_file

CMD [ "apache2-foreground" ]
deez
  • 1,472
  • 3
  • 18
  • 28
  • 1
    Are volumes involved at all, either through a Dockerfile `VOLUME` instruction, a `docker run -v` option, or a Compose `volumes:` block? Can you edit the question to include a [mcve] including in particular the base image you're using and the command you're using to look for the symlink in the container? – David Maze Aug 27 '20 at 13:46
  • Edited the question with my Dockerfile. and no volumes are involved at all. – deez Aug 30 '20 at 07:49

1 Answers1

1

The Dockerfile for that image (three and a half years old and not getting any updates!) has the line:

VOLUME /var/www/html

This will prevent any subsequent RUN instructions from making any changes to that directory, even if it's in a derived image.

There's no way to un-VOLUME a directory, so if you need this symlink to exist, you either need to create a new image from a base PHP image installing the software yourself, or wrap its entrypoint script with your own that creates the symlink at startup time.

David Maze
  • 130,717
  • 29
  • 175
  • 215