alv*_*zsh 6 mysql docker dockerfile
我有下一个dockerfile:
FROM ubuntu:16.04
RUN apt-get update && apt-get upgrade -y && apt-get install -y apache2 mysql-server mysql-client
Run Code Online (Sandbox Code Playgroud)
之后,Docker构建问我密码root:
While not mandatory, it is highly recommended that you set a password for the
MySQL administrative "root" user.
If this field is left blank, the password will not be changed.
New password for the MySQL "root" user:
Run Code Online (Sandbox Code Playgroud)
我输入密码,但是,它只是保持该状态.
我可以这样安装mysql吗?我不想自动安装它
sen*_*rle 23
从某种抽象的意义上来说,接受的答案可能是正确的,但这与手头的事情完全无关.您需要一种静态指定密码的方法.除非你使用官方形象,否则无论你是否遵循"一个过程,一个容器"的教条,你都需要这样做.
答案在这里告诉您如何,但它留下了一个关键的设置:你还是要告诉debconf使用Noninteractive的前端,作为描述在这里.
以下是Dockerfile基于上述内容的工作示例.
FROM ubuntu:latest
MAINTAINER Jonathan Strange <jstrange@norrell.edu>
RUN apt-get update \
&& apt-get install -y apt-utils \
&& { \
echo debconf debconf/frontend select Noninteractive; \
echo mysql-community-server mysql-community-server/data-dir \
select ''; \
echo mysql-community-server mysql-community-server/root-pass \
password 'JohnUskglass'; \
echo mysql-community-server mysql-community-server/re-root-pass \
password 'JohnUskglass'; \
echo mysql-community-server mysql-community-server/remove-test-db \
select true; \
} | debconf-set-selections \
&& apt-get install -y mysql-server apache2 python python-django \
python-celery rabbitmq-server git
Run Code Online (Sandbox Code Playgroud)
这与官方的Dockerfile做法并没有太大的不同- 尽管他们处理实际的密码配置有所不同.
有些人通过设置DEBIAN_FRONTEND环境变量获得了成功noninteractive,如下所示:
ENV DEBIAN_FRONTEND noninteractive
Run Code Online (Sandbox Code Playgroud)
但是,这似乎并不适用于所有情况.debconf直接使用对我来说已经证明更可靠.
Buk*_*gey -1
Docker方式是“一个进程一个容器”。您需要一个用于 apache 的容器和一个用于 mysql 的容器。您可以使用官方的php镜像和官方的mysql镜像
为了链接容器,我建议使用 docker-compose
| 归档时间: |
|
| 查看次数: |
6467 次 |
| 最近记录: |