linuxdocker

docker add file successful, however it doesnot exist in the image


FROM mambaorg/micromamba:2

USER root
WORKDIR /home/mambauser/llmtools # success, this folder really exists
ADD environment.yml . # success, this file really in the image
ADD mypy.ini . # success, this file really in the image
ADD pyproject.toml . # success, this file really in the image
ADD pip.conf /home/mambauser/.config/pip/pip.conf # success, this file really in the image
ADD .condarc /home/mambauser/.condarc # success, this file really in the image

WORKDIR /home/mambauser
ADD surya_models.tar.gz /home/mambauser/ # no error, but this file does not in the image

surya_models.tar.gz really in the work directory. And build successfully without any error. However after I run this image, I found surya_models.tar.gz not exists.

This is my build context.

(llmtools) (base) YYY:PATH/TO/WORKSPACE$ ls -l
total 1334156
-rwxrwxr-x 1 ps ps        269  7月 25 13:11  build.sh
-rw-rw-r-- 1 ps ps       1075  7月 25 13:15  Dockerfile
-rw-rw-r-- 1 ps ps        406  7月 25 10:57  environment.yml
-rw-rw-r-- 1 ps ps        284  4月 10 19:55  mypy.ini
-rw-rw-r-- 1 ps ps         61  7月 21 18:28  pip.conf
-rw-rw-r-- 1 ps ps        280  4月 10 12:34  pyproject.toml
-rwxrwxr-x 1 ps ps        201  7月 25 09:49  run.sh
drwxrwxr-x 4 ps ps       4096  4月 10 19:40  src
-rw-rw-r-- 1 ps ps 1366125260  7月 25 13:18  surya_models.tar.gz
drwxrwxr-x 4 ps ps       4096  4月 11 17:29  test
(llmtools) (base) YYY:PATH/TO/WORKSPACE$ ./build.sh 
[+] Building 9.3s (14/14) FINISHED                                                                                                docker:default
 => [internal] load .dockerignore                                                                                                           0.0s
 => => transferring context: 2B                                                                                                             0.0s
 => [internal] load build definition from Dockerfile                                                                                        0.0s
 => => transferring dockerfile: 1.11kB                                                                                                      0.0s
 => [internal] load metadata for mambaorg/micromamba:2                                                             0.0s
 => [internal] load build context                                                                                                           0.0s
 => => transferring context: 196B                                                                                                           0.0s
 => [1/9] FROM mambaorg/micromamba:2                                                                               0.0s
 => CACHED [2/9] WORKDIR /home/mambauser/llmtools                                                                                           0.0s
 => [3/9] ADD environment.yml .                                                                                                             0.1s
 => [4/9] ADD mypy.ini .                                                                                                                    0.1s
 => [5/9] ADD pyproject.toml .                                                                                                              0.1s
 => [6/9] ADD pip.conf /home/mambauser/.config/pip/pip.conf                                                                                 0.1s
 => [7/9] ADD .condarc /home/mambauser/.condarc                                                                                             0.1s
 => [8/9] WORKDIR /home/mambauser                                                                                                           0.1s
 => [9/9] ADD surya_models.tar.gz /home/mambauser/                                                                                          5.2s
 => exporting to image                                                                                                                      3.5s
 => => exporting layers                                                                                                                     3.4s
 => => writing image sha256:73b4a5a9a333c405f2b72d30d40ce072d7b38886eba10184c4724c886c0f5fb7                                                0.0s
 => => naming to docker.io/library/llmtools:latest                        
(llmtools) (base) YYY:PATH/TO/WORKSPACE$ docker run --rm -ti llmtools:latest sh
# ls
llmtools
# pwd
/home/mambauser
# ls -la
total 40
drwxrwxrwx 1 mambauser mambauser 4096 Jul 25 05:29 .
drwxrwxrwx 1 root      root      4096 Jul  1 16:04 ..
-rwxrwxrwx 1 mambauser mambauser  220 Apr 18 22:47 .bash_logout
-rwxrwxrwx 1 mambauser mambauser 3573 Jul  1 16:04 .bashrc
drwxr-xr-x 3 root      root      4096 Jul 25 05:29 .cache
-rw-rw-r-- 1 root      root       772 Jul 21 10:16 .condarc
drwxr-xr-x 3 root      root      4096 Jul 25 05:29 .config
-rwxrwxrwx 1 mambauser mambauser  807 Apr 18 22:47 .profile
drwxr-xr-x 1 root      root      4096 Jul 25 05:29 llmtools
# 

Solution

  • When ADDing a tar archive, the archive is decompressed as documented here. So you should be able to see the content of the archive in the image.

    If you don't want the archive to be decompressed, use COPY instead of ADD.