I'm creating a Dockerfile, but seem to be having some issues navigating to the folder of a cloned repo
My file contains the below
FROM ubuntu:latest
MAINTAINER cagnulein
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Moscow
ENV MAKEFLAGS -j8
WORKDIR /usr/local/src
RUN apt-get update && apt-get install -y tzdata
RUN apt -y update
RUN apt -y upgrade
RUN apt update -y && apt-get install -y git qt5-default libqt5bluetooth5 libqt5widgets5 libqt5positioning5 libqt5xml5 qtconnectivity5-dev qtpositioning5-dev libqt5charts5-dev libqt5charts5 qt5-default libqt5networkauth5-dev libqt5websockets5* libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev build-essential
RUN cd ~
RUN git clone https://github.com/cagnulein/qdomyos-zwift.git
RUN ls -alh
RUN cd ~/qdomyos-zwift
I successfully clone the repo, and can confirm the folder exists, but I can't seem to navigate to it as I get the following
#13 [ 9/15] RUN ls -alh
#13 sha256:4b5dfb1969e228b79ed0f0d06393eddbc97c0197582b068ad75b1e5672597867
#13 0.361 total 16K
#13 0.361 drwxr-xr-x 1 root root 4.0K Mar 30 20:31 .
#13 0.361 drwxr-xr-x 1 root root 4.0K Mar 16 20:07 ..
#13 0.361 drwxr-xr-x 17 root root 4.0K Mar 30 20:31 qdomyos-zwift
#13 DONE 0.4s
#14 [10/15] RUN cd ~/qdomyos-zwift
#14 sha256:c875dc5e19a73f6e654af2feb63f14be8a945e8eefe4882f4cd64962dd90d399
#14 0.437 /bin/sh: 1: cd: can't cd to /root/qdomyos-zwift
#14 ERROR: executor failed running [/bin/sh -c cd ~/qdomyos-zwift]: exit code: 2
Any ideas?
Tried
WORKDIR ~
RUN git clone https://github.com/cagnulein/qdomyos-zwift.git
RUN ls -alh
WORKDIR ~/domyos-zwift
RUN git submodule update --init src/smtpclient/
which fails with
#13 0.466 fatal: not a git repository (or any of the parent directories): .git
#13 ERROR: executor failed running [/bin/sh -c git submodule update --init src/smtpclient/]: exit code: 128
------
> [11/15] RUN git submodule update --init src/smtpclient/:
------
executor failed running [/bin/sh -c git submodule update --init src/smtpclient/]: exit code: 128
Notice in your example that you already have seen the mechanism to set the current directory: WORKDIR
.
Replace all of your RUN cd ...
statements with WORKDIR /path
instead. That's the correct way to set the current directory in a Dockerfile.
If you need to be in another place at the end of your build, remember to add a WORKDIR
toward the end of the file to leave that as the working directory in the final image.