基于commit命令创建docker镜像

木木2年前技术文章695

创建docker容器

```Plain Text sudo docker run -it centos:centos7 /bin/bash

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142038.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142038.png)

## 替换yum源

Plain Text

备份原来的源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

获取新的源

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

生成缓存

yum makecache

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142604.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142604.png)

## 安装和配置python3和django服务

Plain Text yum install -y python3 python3-pip

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142241.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161142241.png)

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143453.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143453.png)

Shell

安装django

pip3 install django

创建django项目

django-admin startproject djangotest

修改配置文件

vim djangotest/djangotest/settings.py    ALLOWED_HOSTS = ['*',]

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143016.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143016.png)

## 编写启动脚本

Plain Text vi run.sh python3 /www/djangotest/manage.py runserver 0.0.0.0:8000 chmod +x run.sh

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143040.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143040.png)

## 使用commit命令生成新镜像

Plain Text docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

![https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143466.png](https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143466.png)

## 使用新镜像

Plain Text sudo docker run -p 10080:8000 -d centos:django sh /www/run.sh ```

https://teamo-md.oss-cn-shanghai.aliyuncs.com/img/202108161143841.png


相关文章

数据湖技术之iceberg(六)Iceberg表数据组织与查询

数据湖技术之iceberg(六)Iceberg表数据组织与查询

1     Iceberg表数据组织与查询1) 下载avro-tools jar包由于后期需要查看avro文件内容,我们可以通过avro-tool.jar来查看...

MySQL DDL 风险评估

MySQL DDL 风险评估

一、前言变更是数据库离不开的话题,从 MySQL 5.6 开始,推出 online DDL 即变更期间不锁表,本篇文章介绍 MySQL 变更对数据库的影响如何去判断。二、DDL 风险提示1. 变更速查...

iotop-监控磁盘I/O

iotop-监控磁盘I/O

iotop概述iotop 是一个类似 top 的工具,用来显示实时的磁盘活动。Linux下的IO统计工具如iostat,nmon等大多数是只能统计到per设备的读写情况。iotop 监控 Linux...

MySQL性能优化(七)优化or查询的另一个例子

MySQL性能优化(七)优化or查询的另一个例子

优化or查询的另外一个例子。一个例子SELECT msg.msg_id, msg.content , … FROM msg   ...

HDFS业务类型与相关架构优化措施

低延迟业务计算密集型业务,低延迟业务,这一类业务通常是对大量NameNode文件目录访问为主的(权限判断,文件存在性,文件信息查询等对NameNode元数据操作为主的)。因此需要针对NameNode的...

Solr常用API详细操作

Solr常用API详细操作

1. 监督集群的状态和统计返回监督器(overseer)的当前状态,各种监督器API的性能统计信息以及每种操作类型的最近10次故障/admin/collections?action=OVERSEERS...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。