【发布时间】:2020-04-18 02:01:43
【问题描述】:
我正在尝试在我的 docker 应用程序中安装 mysql,但在运行“docker-compose build”时我的 Dockerfile 中出现错误。
我的 docker-compose.yml :
services:
database:
container_name: mysql_database
build: ./docker/mysql
command: --max_allowed_packet=256M
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: root
MYSQL_PASSWORD: root
MYSQL_CHARSET: utf8
MYSQL_COLLATION: utf8
我的 Dockerfile:
FROM mysql:5.7
# Install packages
RUN apt-get update --yes && apt-get install --yes procps
RUN apt-get install --yes \
apt-utils \
curl \
git \
htop \
man \
mlocate \
mysql-client \
zlib1g-dev \
zip \
unzip \
vim \
wget
COPY root/.vimrc /root/.vimrc
COPY root/.bashrc /root/.bashrc
WORKDIR /var/lib/mysql
显示错误:
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
ERROR: Service 'database' failed to build: The command '/bin/sh -c apt-get install --yes apt-utils curl git htop man mlocate mysql-client zlib1g-dev zip unzip vim wget' returned a non-zero code: 100
我的配置或命令有什么问题?
【问题讨论】:
-
我会在你的第一个命令中插入一个升级,所以让它
apt-get update --yes && apt-get upgrade --yes && apt-get install --yes procps。这意味着您正在使用最新版本。 -
如果这没有帮助,还是坚持下去,然后暂时修剪你的第二个软件列表,直到发现问题所在。缩小那是什么。也许您为可安装项目使用了错误的名称。
-
现在我有,
Errors were encountered while processing: /tmp/apt-dpkg-install-8rvoCi/2-mysql-community-server_5.7.29-1debian9_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) ERROR: Service 'database' failed to build: The command '/bin/sh -c apt-get update --yes && apt-get upgrade --yes' returned a non-zero code: 100 -
为什么需要
htop、git、man、vim或 shell 点文件来运行数据库?为什么不能运行未修改的mysql:5.7数据库镜像? -
您可以尝试单独执行
apt-get install -yq包,看看哪个包给您带来了麻烦。特别是由于它的大小,我会单独在命令中安装 mysql-client。
标签: mysql docker docker-compose