写一个dockerfile,centos 8的镜像,安装yum并更新国内的源,通过yum安装python3和pip、nodejs环境,并更新pip为国内的源,通过pip安装flask
时间: 2023-04-06 19:04:39 浏览: 213
以下是 Dockerfile 的内容:
```
FROM centos:8
# 安装 yum 并更新国内源
RUN dnf install -y yum && \
yum install -y epel-release && \
yum install -y https://mirrors.aliyun.com/centos/8.4.2105/BaseOS/x86_64/os/Packages/centos-linux-repos-8-4.el8.noarch.rpm && \
yum install -y https://mirrors.aliyun.com/centos/8.4.2105/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-4.el8.noarch.rpm && \
yum install -y https://mirrors.aliyun.com/centos/8.4.2105/BaseOS/x86_64/os/Packages/centos-linux-release-8.4-1.2105.el8.x86_64.rpm && \
yum clean all && \
rm -rf /var/cache/yum/*
# 安装 Python3 和 pip
RUN yum install -y python3 python3-pip
# 更新 pip 为国内源
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip
# 安装 Node.js
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash -
RUN yum install -y nodejs
# 安装 Flask
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ flask
```
你可以使用以下命令构建镜像:
```
docker build -t my-flask-app .
```
然后使用以下命令运行容器:
```
docker run -p 5000:5000 my-flask-app
```
这将在本地的 5000 端口启动 Flask 应用程序。
阅读全文