Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile 'RUN git clone' removes intermediate container

I using Boot2Docker on Windows 7 to build my developement environment with a Dockerfile. When i run docker build -t myimage dir/of/docker/file, then everything works fine until this line:

RUN git clone --verbose https://github.com/zsh-users/antigen ~/.antigen/antigen

The output of this line is:

Step 12 : RUN git clone --verbose https://github.com/zsh-users/antigen ~/.antigen/antigen
---> Running in 26cba91e912a
Cloning into '/root/.antigen/antigen'...
POST git-upload-pack (302 bytes)
---> e0012659884b
Removing intermediate container 26cba91e912a
Successfully built e0012659884b

The clone (of a public repository) is droped, the ~/.antigen/antigen isn't exists in the container. The "Cloning into..." is red, so i think there is something wrong with the command. But if i'm running it in the container's shell (opened by docker run -it myimage) it clones it.

Am i doing something wrong, or may i do some setup to use git clone in dockerfile? Here's the full content of it:

FROM debian:testing
MAINTAINER BimbaLaszlo

RUN apt-get update

RUN apt-get install -y curl

RUN apt-get install -y gcc g++ make
RUN apt-get install -y ctags
RUN apt-get install -y git

RUN apt-get install -y python python-pip python3 python3-pip

RUN apt-get install -y ruby ruby-dev
RUN gem install ripper-tags gem-ripper-tags
RUN gem install pry byebug

RUN apt-get install -y zsh
RUN git clone --progress --verbose https://github.com/zsh-users/antigen ~/.antigen/antigen
like image 687
bimlas Avatar asked May 19 '26 15:05

bimlas


1 Answers

The color you see in red, is not caused by error. It's because git clone doesn't use STDOUT, we can verity it by following command:

$ git clone --progress --verbose https://github.com/zsh-users/antigen > /dev/null
Cloning into 'antigen'...
POST git-upload-pack (255 bytes)
remote: Counting objects: 1291, done.
remote: Total 1291 (delta 0), reused 0 (delta 0), pack-reused 1291
Receiving objects: 100% (1291/1291), 1.10 MiB | 900.00 KiB/s, done.
Resolving deltas: 100% (688/688), done.
Checking connectivity... done.

$ git clone --progress --verbose https://github.com/zsh-users/antigen 2&> /dev/null

In the first command, I redirected all STDOUT into /dev/null, we can still see the output. But in the second command, I redirected all STDERR into /dev/null, so we saw nothing.

And in docker build, if any output is not in STDOUT, it will turn RED. That's it.

So nothing is wrong with your Dockerfile.

like image 132
david30xie Avatar answered May 22 '26 06:05

david30xie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!