dockerfile在ubuntu映像中安装mysql并运行脚本

时间:2019-10-09 08:12:14

标签: python mysql docker ubuntu

我们如何创建一个简单的docker文件,该文件可以运行mysql数据库并执行某些文件夹
中的脚本,例如 scripts-folder
,然后运行python应用程序此mysql数据库内部。

目前,我有一个Dockerfile来创建mysql docker镜像并在其上运行脚本,但是我不想为数据库工作创建一个单独的docker镜像。

# Derived from official mysql image (our base image)
FROM mysql
# Add a database
ENV MYSQL_DATABASE mydatabase
# Add the content of the sql-scripts/ directory to your image
# All scripts in docker-entrypoint-initdb.d/ are automatically
# executed during container startup
COPY ./sql-scripts/ /docker-entrypoint-initdb.d/


但是,我只需要有1个同时在内部运行mysql和python应用程序的ubuntu docker映像即可。

1 个答案:

答案 0 :(得分:0)

尝试添加这些行

RUN sudo apt-get update
RUN sudo apt-get install python
COPY <path/to/your/script.py>
CMD [ "python3", "script.py" ]

更多信息:

Dockerize python app

Install python into a docker image