Docker : RUN cd … does not work as expected [duplicate]

It is actually expected.

A dockerfile is nothing more but a wrapper on docker run + docker commit.

FROM ubuntu:12.10
RUN mkdir tmp123
RUN cd tmp123
RUN pwd

Is the same thing as doing:

CID=$(docker run ubuntu:12.10 mkdir tmp123); ID=$(docker commit $CID)
CID=$(docker run $ID cd tmp123); ID=$(docker commit $CID)
CID=$(docker run $ID pwd); ID=$(docker commit $CID)

Each time you RUN, you spawn a new container and therefore the pwd is “https://stackoverflow.com/”.

If you feel like it, you can open an issue on github in order to add a CHDIR instruction to Dockerfile.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)