代码改变世界

Dockerfile制作应用镜像

2020-10-16 18:02  DataBases  阅读(156)  评论(0编辑  收藏  举报

agc-backend镜像制作

/opt/AGC-backend
[root@dadevenv AGC-backend]# ls
agc_setting config eventLog master recipe unit_test
alarm datastore helpers Pipfile requirements.txt user_group
analysis Dockerfile insertParam.py Pipfile.lock SECS
auth eqsetting logger process systemConfig
common equipmentStatus main.py README.txt tools
[root@dadevenv AGC-backend]# cat Dockerfile

FROM centos:7.6.1810
COPY . /agc-backend
WORKDIR /agc-backend
RUN yum install -y gcc gcc-c++ && yum install -y postgresql-devel* && yum install -y python3-devel
RUN yum install -y python36
RUN pip3 install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

#RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
EXPOSE 5000
CMD nohup python3 main.py &

[root@dadevenv AGC-backend]# cat requirements.txt
DBUtils
flask
flask-restful
flask_cors
json-rpc
psycopg2
requests
prompt-toolkit
scikit-learn
scipy
numpy
pyjwt
[root@dadevenv AGC-backend]# docker image build -t agc-backend:1.0.0 .

[root@dadevenv ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
agc-backend 1.0.0 83ce0368f03d 3 minutes ago 1.32GB
python 3.6 94b7a322c796 2 days ago 874MB
timescale/timescaledb latest-pg11 5f6d3db88e6c 5 weeks ago 178MB
postgres 11.8 31d22a1554df 2 months ago 282MB
[root@dadevenv ~]# docker save -o agc-backend.tar.gz agc-backend:1.0.0
[root@dadevenv ~]# ls
agc-backend.tar.gz initial-setup-ks.cfg path.py pg118 postgresql11.8.tar PycharmProjects timescaledb11.tar
anaconda-ks.cfg jupyternotebook_start.sh pg114 pgdata postgresql.tar timescale11 timescaledb.tar

https://yq.aliyun.com/articles/727210

https://www.runoob.com/docker/docker-dockerfile.html

https://blog.fundebug.com/2017/05/15/write-excellent-dockerfile/

https://cloud.tencent.com/developer/article/1456990

https://shixiongfei.com/

https://yeasy.gitbook.io/docker_practice/image/dockerfile
https://juejin.im/post/6844903976073166862
https://blog.fundebug.com/2017/05/15/write-excellent-dockerfile/
https://shixiongfei.com/
https://shixiongfei.com/docker-note.html

修改Docker容器时区

https://www.cnblogs.com/zhi-leaf/p/10604574.html

查看linux系统时区和docker容器时区

date -R                          //查看linux主机时间和时区
date exec [container] date -R    // 查看容器时间和时区

[root@dadevenv ~]# date -R
Thu, 22 Oct 2020 14:04:31 +0800

[root@dadevenv ~]# docker exec -it 11c0dd3702f6 bash

root@11c0dd3702f6:/agc-backend# date -R
Thu, 22 Oct 2020 06:09:00 +0000
root@11c0dd3702f6:/agc-backend# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
root@11c0dd3702f6:/agc-backend# date -R
Thu, 22 Oct 2020 14:09:32 +0800

[root@dadevenv ~]# docker restart 11c0dd3702f6
11c0dd3702f6

[root@dadevenv ~]# docker exec 11c0dd3702f6 date -R
Thu, 22 Oct 2020 14:19:44 +0800
[root@dadevenv ~]# docker exec -it 11c0dd3702f6 bash
root@11c0dd3702f6:/agc-backend# date -R
Thu, 22 Oct 2020 14:20:00 +0800