docker 镜像仓库推送
 

0x01 构建镜像

FROM python:3.8

WORKDIR /home
COPY . /home

RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com -r requirements.txt

# RUN  python manage.py makemigrations  &&  python manage.py migrate
# CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]

RUN chmod +x run.sh
EXPOSE 8000
CMD ["/bin/sh","run.sh"]
docker build -t lghost/blog:latest .
# build images

0x02 测试镜像

bash docker.wuyou.run

# 启动容器demo

sudo docker stop blog  > /dev/null 2>&1
sudo docker rm blog  > /dev/null 2>&1
sudo docker run  --name blog -d \
 -c 1024 \
 -m 500M \
 --log-opt max-size=10m --log-opt max-file=3 \
 --restart=always \
 -p 8000:8000 \
 -e REDIS_HOST=192.168.1.100 \
 -e REDIS_PORT=6379 \
 -e DB_HOST=192.168.1.100 \
 -e DB_PORT=63306 \
 -e DB_USER=admin \
 -e DB_PASSWORD='passwd' \
 -e DB_NAME=wy_web \
lghost/blog

0x03 推送镜像

docker login
# 认证登录

docker push lghost/blog:latest
# 推送到dockerhub

文章作者: 以谁为师
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源!

  目录