Change directory command in Docker?

RParadox picture RParadox · Dec 17, 2013 · Viewed 263.5k times · Source

In docker I want to do this:

git clone XYZ
cd XYZ
make XYZ

However because there is no cd command, I have to pass in the full path everytime (make XYZ /fullpath). Any good solutions for this?

Answer

Javier Castellanos picture Javier Castellanos · Nov 4, 2014

To change into another directory use WORKDIR. All the RUN, CMD and ENTRYPOINT commands after WORKDIR will be executed from that directory.

RUN git clone XYZ 
WORKDIR "/XYZ"
RUN make