社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  docker

在Docker中安装NCL

happy科研 • 3 年前 • 570 次点击  

最近为 sokort 项目封装 Docker 镜像,需要在镜像中安装 NCL 环境。使用的基础镜像 (jupyter/scipy-notebook 和 continuumio/miniconda) 属于 debian buster 系列,安装的 NCL 版本较高,绘图脚本访问 GRAPES 系列模式 GRIB2 数据会出错,需要安装业务系统使用的 NCL 6.4.0 版本。官网下载的预编译包依赖 libgfortran3 库,不能直接使用 apt 安装,需要进行额外配置。

下面介绍如何在 Ubuntu 20.04 和 Debian buster 的 Docker 镜像中安装 NCL 6.4.0 版本。

准备

从官方渠道下载 NCL 预编译包。本文下载的软件包是

ncl_ncarg-6.4.0-Debian8.6_64bit_nodap_gnu492.tar.gz

Ubuntu 20.04 (jupyter/scipy-notebook)

准备 apt 源文件 sources.list,本文使用 CMA 镜像站加速。注意添加 Ubuntu 18.04 (bionic) 源。

deb http://mirrors.cma.cn/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.cma.cn/ubuntu/ focal-updates main restricted universe multiversemultiverse
deb http://mirrors.cma.cn/ubuntu/ focal-backports main restricted universe multiverse

deb http://mirrors.cma.cn/ubuntu/ bionic main universe

在 Dockerfile 文件中覆盖 /etc/apt/sources.list 并安装 g++-6 和 libgfortran3

COPY sources.list /etc/apt/sources.listRUN apt-get update -y && apt-get install -y g++-6 && \    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 6 && \    apt-get install libgfortran3


拷贝 NCL 预编译包并解压缩

COPY ncl_ncarg-6.4.0-Debian8.6_64bit_nodap_gnu492.tar.gz /srv/ncl/ncl.tar.gzRUN cd /srv/ncl && tar zxf ncl.tar.gz && rm -rf ncl.tar.gz

设置 NCL 环境变量 NCARG_ROOT,并修改 PATH

ENV NCARG_ROOT="/srv/ncl"ENV PATH="/srv/ncl/bin:${PATH}"

经过以上配置,ncl 可执行程序在生成的镜像中可以直接运行。

Debian buster (continuumio/miniconda)

与 Ubuntu 类似。

准备 apt 源文件 sources.list。注意添加 stretch 源。

deb http://mirrors.cma.cn/debian/ buster main contrib non-free
deb http://mirrors.cma.cn/debian/ buster-updates main contrib non-free
deb http://mirrors.cma.cn/debian/ buster-backports main contrib non-free
deb http://mirrors.cma.cn/debian-security buster/updates main contrib non-free

deb http://mirrors.cma.cn/debian stretch main contrib non-free

在 Dockerfile 文件中覆盖 /etc/apt/sources.list 并安装 g++-6fontconfig 和 libgfortran3

COPY sources.list /etc/apt/sources.listRUN apt-get update -y && apt-get install -y gcc-6/stretch fontconfig \    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 6 \    && apt-get install -y libgfortran3/stretch

其余部分与 Ubuntu 相同。

参考

在 Docker 中使用 Anaconda

查看 Dockerfile 请访问 sokort 项目:

https://github.com/nwpc-oper/sokort



题图由 Willgard Krause 在 Pixabay 上发布。
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/120976
 
570 次点击