【问题标题】:Dockerfile Mysql - Errors were encountered while processingDockerfile Mysql - 处理时遇到错误
【发布时间】: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
  • 为什么需要 htopgitmanvim 或 shell 点文件来运行数据库?为什么不能运行未修改的mysql:5.7 数据库镜像?
  • 您可以尝试单独执行apt-get install -yq 包,看看哪个包给您带来了麻烦。特别是由于它的大小,我会单独在命令中安装 mysql-client。

标签: mysql docker docker-compose


【解决方案1】:

根据您的最新评论更新,目前您遇到的问题是不可重现的。对我来说效果很好。

Dockerfile:

FROM mysql:5.7

RUN apt-get update --yes && apt-get upgrade --yes

构建命令:

docker build -t docker-build-test .

输出:

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM mysql:5.7
5.7: Pulling from library/mysql
123275d6e508: Pull complete 
27cddf5c7140: Pull complete 
c17d442e14c9: Pull complete 
5fc78b1e06f8: Pull complete 
cd38802f42bb: Pull complete 
b370e336f220: Pull complete 
f519d6d4d2f6: Pull complete 
93fcd48f8a46: Pull complete 
52b3f78c0999: Pull complete 
0692e317044b: Pull complete 
bdf7d9d2736f: Pull complete 
Digest: sha256:7924ec534b844f9c7c0547fa95265516e8adf19ca475cffe911202037392d264
Status: Downloaded newer image for mysql:5.7
 ---> 66371c06f4ca
Step 2/2 : RUN apt-get update --yes && apt-get upgrade --yes
 ---> Running in 6c6b003973ad
Get:1 http://repo.mysql.com/apt/debian buster InRelease [21.5 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster InRelease [122 kB]
Get:4 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:5 http://repo.mysql.com/apt/debian buster/mysql-5.7 amd64 Packages [5680 B]
Get:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages [187 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:8 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Fetched 8365 kB in 23s (369 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Removing intermediate container 6c6b003973ad
 ---> e50d1485ef7f
Successfully built e50d1485ef7f
Successfully tagged docker-build-test:latest

此构建成功。您能否修改您的问题,并将 Dockerfile 缩减为可能的最小失败案例?也可能值得添加您的主机操作系统和 Docker 版本号。

【讨论】:

  • @AshadKhan:我刚刚在这个容器docker run -it docker-build-test bash 上获得了一个shell,然后成功运行了客户端mysql,没有进一步安装任何东西。换句话说,这可能是您的问题 - 客户端已安装在此映像中。
猜你喜欢
  • 1970-01-01
  • 2020-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-03
  • 1970-01-01
  • 2014-07-24
  • 1970-01-01
相关资源
最近更新 更多