Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change directory command in Docker?

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?

like image 530
RParadox Avatar asked Dec 17 '13 10:12

RParadox


People also ask

How do I change a directory in Docker?

Just use the WORKDIR command to change the directory you want to. Any other commands you use beyond this command will be executed in the directory you have set. It is also a better practice to make use of WORKDIR in docker.

Does Workdir change directory?

No. WORKDIR affects the working directory inside the container. In the original example, the first COPY copies from package.

How do I see the directory in Docker?

to find the root directory of docker. You will find the docker directory will be given in this line: "Docker Root Dir: /var/lib/docker". The docker images, they are stored inside the docker directory: /var/lib/docker/ images are stored there.

Where is the root directory of Docker?

By default, Docker stores most of its data inside the /var/lib/docker directory on Linux systems.


1 Answers

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 
like image 162
Javier Castellanos Avatar answered Oct 02 '22 17:10

Javier Castellanos