下载镜像
搜索官方的下载名称:https://hub.docker.com/_/centos/tags
bash
docker pull centos:centos7.9.2009
Dockerfile
bash
# 镜像
FROM centos7.9.2009
#维护者信息
LABEL maintainer 122286911@qq.com
# GCC编译器wget
RUN yum install -y gcc wget
# Python依赖
RUN yum install -y patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# 目录
RUN mkdir -p /data/
WORKDIR /data/
# SQLite 升级
RUN wget https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz --no-check-certificate
RUN tar -zxvf sqlite-autoconf-3420000.tar.gz
WORKDIR /data/sqlite-autoconf-3420000
RUN ./configure
RUN make && make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
# Python3.9环境
WORKDIR /data/
RUN wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
RUN tar -xvf Python-3.9.5. tgz
WORKDIR / data/Python-3.9.5/
RUN ./configure
RUN make && make install
RUN pip3.9 config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple/
# git
RUN yum install git -y
RUN git config --global user.name"隆海"
RUN git config --global user.email "122286911@qq.com "
# git拉代码
WORKDIR / data/
RUN git clone https://gitee.com/wupeiqi/blog.git
#虚拟环境
RUN pip3.9 install virtualenv
RUN virtualenv /envs/dj --python=python3.9
RUN /envs/dj/bin/pip3.9 install django==3.2
# 运行项目
WORKDIR /data/blog
CMD ["/envs/dj/bin/python", "manage.py", "runserver", "0.0.0.0:9000"]
bash
docker build -t myblogimage .
bash
docker run -d \
-v /Users/rh/python/dj:/app \
-p 8080:8080 \
--name myblog \
myblog_image \
uwsgi --ini /app/uwsgi_myblog.ini