alexey2baranov
alexey2baranov

Reputation: 409

How can I make dir inside docker image?

Why i get error?

Dockerfile

FROM certbot/certbot

WORKDIR /
RUN mkdir -p /etc/letsencrypt/live
RUN cd /etc/letsencrypt/live

docker build --no-cache .

/bin/sh: cd: line 1: can't cd to /etc/letsencrypt/live: No such file or directory

Upvotes: 0

Views: 333

Answers (2)

David Maze
David Maze

Reputation: 159752

If you look at the Docker Hub certbot/certbot page, click on "Tags", and select one of the tags, you can get an automated dump of the build sequence for the image. Of note, that contains a line

VOLUME [/etc/letsencrypt /var/lib/letsencrypt]

A directory that's marked as a VOLUME in a Dockerfile can't be subsequently modified by RUN commands, even in a derived image; changes will just be discarded.

Upvotes: 1

lazylead
lazylead

Reputation: 1989

As a workaround, you may try to add there an empty file from outside into that directory

ADD readme.txt /etc/letsencrypt/live/readme.txt

Upvotes: 0

Related Questions