我正在尝试在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
我的配置或命令出了什么问题?
答案 0 :(得分:0)
根据最新的评论更新,当前存在的问题无法重现。对我来说很好。
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版本号。