MiniBullLab / easy_docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

镜像大小优化

vitahlin opened this issue · comments

方案

  • 1. docker-squash
  • 2. 删除RUN缓存
  • 3. multi-stage

参考链接:

初始大小:

REPOSITORY          TAG                      IMAGE ID       CREATED      SIZE
easy_lib            latest                   2fb497e72891   2 days ago   16.4GB
minbull/easy_base   1.0.0                    edb431df719b   3 days ago   3.67GB
easy_base           latest                   edb431df719b   3 days ago   3.67GB
nvidia/cuda         10.0-devel-ubuntu18.04   c6abe772d510   5 days ago   2.24GB
E: Package 'libssl-dev' has no installation candidate
ERROR: Service 'base_v1' failed to build: The command '/bin/sh -c apt-get install -y libssl-dev &&     apt-get remove -y cmake &&     curl -L -O http://118.31.19.101:8080/software/utility/cmake-3.14.0.tar.gz &&     tar -vxf cmake-3.14.0.tar.gz &&     cd cmake-3.14.0/ &&     ./bootstrap &&     make &&     sudo make install &&     cmake --version &&     rm -rf /cmake-3.14.0.tar.gz  /cmake-3.14.0' returned a non-zero code: 100

执行方案2后,大小:

easy_base_v1        latest                   fe5aa8e16df6   5 minutes ago       3.61GB

cmake安装位置

root@f36b209019b5:/usr/local/bin# ll
total 44736
drwxr-xr-x 1 root root     4096 May 11 14:12 ./
drwxr-xr-x 1 root root     4096 May 11 14:12 ../
-rwxr-xr-x 1 root root 14843400 May 11 14:11 cmake*
-rwxr-xr-x 1 root root 14912496 May 11 14:10 cpack*
-rwxr-xr-x 1 root root 16037472 May 11 14:11 ctest*

cmake处理后大小

easy_base_v1        latest    7663e43acf51   About a minute ago   3.58GB

cudnn的安装路径是什么

root@113a200d68d6:/usr/local# ls
bin  cuda  cuda-10.0  etc  games  include  lib  man  sbin  share  src

@lpj0822

/usr/lib/x86_64-linux-gnu/

cudnn所需文件:

root@113a200d68d6:/usr/lib/x86_64-linux-gnu# ll | grep cudnn
lrwxrwxrwx  1 root root        29 May 16 09:03 libcudnn.so -> /etc/alternatives/libcudnn_so
lrwxrwxrwx  1 root root        17 Apr 16  2019 libcudnn.so.7 -> libcudnn.so.7.5.1
-rw-r--r--  1 root root 356035144 Apr 16  2019 libcudnn.so.7.5.1
lrwxrwxrwx  1 root root        32 May 16 09:03 libcudnn_static.a -> /etc/alternatives/libcudnn_stlib
-rw-r--r--  1 root root 353886738 Apr 16  2019 libcudnn_static_v7.a

cudnn处理完大小:

easy_base_v1        latest    17640d8bf554   8 minutes ago       4.63GB

镜像更大了,有可能是因为多个COPY命令的问题

cudnn暂时不处理

主要问题解决依赖库的重复问题

依赖库的问题另建issue处理