0
0

More than 1 year has passed since last update.

django-mysql環境をコンテナ化する際にぶつかったエラー

Posted at

概要

  • こちらの記事を元にdocker-compose up -dをしようとすると以下のエラーになった。
エラー内容
docker-django % docker-compose up -d         
Creating network "docker-django_default" with the default driver
Building db
[+] Building 2.2s (9/9) FINISHED                                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                                               0.1s
 => => transferring dockerfile: 37B                                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/mysql:8.0                                                                                                                                       2.1s
 => [auth] library/mysql:pull token for registry-1.docker.io                                                                                                                                       0.0s
 => [internal] load build context                                                                                                                                                                  0.0s
 => => transferring context: 28B                                                                                                                                                                   0.0s
 => [1/3] FROM docker.io/library/mysql:8.0@sha256:152cf187a3efc56afb0b3877b4d21e231d1d6eb828ca9221056590b0ac834c75                                                                                 0.0s
 => CACHED [2/3] COPY ./my.cnf /etc/mysql/conf.d/my.cnf                                                                                                                                            0.0s
 => CACHED [3/3] RUN chmod 644 /etc/mysql/conf.d/my.cnf                                                                                                                                            0.0s
 => exporting to image                                                                                                                                                                             0.0s
 => => exporting layers                                                                                                                                                                            0.0s
 => => writing image sha256:64fcc268d08c8ccd8c0eebde4fe6af9645ebbb31680d8c3fc8e9d66eaa4d5a47                                                                                                       0.0s
 => => naming to docker.io/library/docker-django_db                                                                                                                                                0.0s
WARNING: Image for service db was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Building app
[+] Building 39.1s (10/14)                                                                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                                                               0.0s
 => => transferring dockerfile: 596B                                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/python:3.9.13-slim                                                                                                                              2.1s
 => [auth] library/python:pull token for registry-1.docker.io                                                                                                                                      0.0s
 => [internal] load build context                                                                                                                                                                  0.0s
 => => transferring context: 626B                                                                                                                                                                  0.0s
 => [1/9] FROM docker.io/library/python:3.9.13-slim@sha256:ea93ec4fbe8ee1c62397410c0d1f342a33199e98cd59adac6964b38e410e8246                                                                        0.0s
 => CACHED [2/9] RUN mkdir /workspace                                                                                                                                                              0.0s
 => CACHED [3/9] WORKDIR /workspace                                                                                                                                                                0.0s
 => CACHED [4/9] COPY requirements.txt /workspace/                                                                                                                                                 0.0s
 => ERROR [5/9] RUN apt-get update --fix-missing &&     apt-get -y install gcc libmariadb-dev                                                                                                     36.9s
------                                                                                                                                                                                                  
 > [5/9] RUN apt-get update --fix-missing &&     apt-get -y install gcc libmariadb-dev:                                                                                                                 
#10 1.082 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]                                                                                                                                
#10 1.105 Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]                                                                                                             
#10 1.122 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]                                                                                                                       
#10 1.245 Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]                                                                                                                     
#10 1.434 Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [167 kB]
#10 1.489 Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
#10 2.424 Fetched 8560 kB in 2s (4176 kB/s)
#10 2.424 Reading package lists...
#10 2.996 Reading package lists...
#10 3.543 Building dependency tree...
#10 3.674 Reading state information...
#10 3.857 The following additional packages will be installed:
#10 3.857   binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-10
#10 3.858   fontconfig-config fonts-dejavu-core gcc-10 libasan6 libatomic1 libbinutils
#10 3.858   libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0
#10 3.858   libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libfontconfig1 libfreetype6
#10 3.858   libgcc-10-dev libgd3 libgomp1 libisl23 libitm1 libjbig0 libjpeg62-turbo
#10 3.859   liblsan0 libmariadb3 libmd0 libmpc3 libmpfr6 libnsl-dev libpng16-16
#10 3.859   libquadmath0 libssl-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp6
#10 3.859   libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxpm4 linux-libc-dev
#10 3.860   manpages manpages-dev mariadb-common mysql-common sensible-utils ucf
#10 3.860   zlib1g-dev
#10 3.862 Suggested packages:
#10 3.862   binutils-doc cpp-doc gcc-10-locales gcc-multilib make autoconf automake
#10 3.862   libtool flex bison gdb gcc-doc gcc-10-multilib gcc-10-doc glibc-doc
#10 3.862   libgd-tools libssl-doc man-browser
#10 4.215 The following NEW packages will be installed:
#10 4.215   binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-10
#10 4.216   fontconfig-config fonts-dejavu-core gcc gcc-10 libasan6 libatomic1
#10 4.216   libbinutils libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0
#10 4.216   libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libfontconfig1 libfreetype6
#10 4.216   libgcc-10-dev libgd3 libgomp1 libisl23 libitm1 libjbig0 libjpeg62-turbo
#10 4.216   liblsan0 libmariadb-dev libmariadb3 libmd0 libmpc3 libmpfr6 libnsl-dev
#10 4.217   libpng16-16 libquadmath0 libssl-dev libtiff5 libtirpc-dev libtsan0 libubsan1
#10 4.217   libwebp6 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxpm4
#10 4.218   linux-libc-dev manpages manpages-dev mariadb-common mysql-common
#10 4.218   sensible-utils ucf zlib1g-dev
#10 4.264 0 upgraded, 60 newly installed, 0 to remove and 0 not upgraded.
#10 4.264 Need to get 57.5 MB of archives.
#10 4.264 After this operation, 203 MB of additional disk space will be used.
#10 4.264 Get:1 http://deb.debian.org/debian bullseye/main amd64 sensible-utils all 0.0.14 [14.8 kB]
#10 4.273 Get:2 http://deb.debian.org/debian bullseye/main amd64 manpages all 5.10-1 [1412 kB]
#10 4.321 Get:3 http://deb.debian.org/debian bullseye/main amd64 ucf all 3.0043 [74.0 kB]
#10 4.321 Get:4 http://deb.debian.org/debian bullseye/main amd64 binutils-common amd64 2.35.2-2 [2220 kB]
#10 4.361 Get:5 http://deb.debian.org/debian bullseye/main amd64 libbinutils amd64 2.35.2-2 [570 kB]
#10 4.372 Get:6 http://deb.debian.org/debian bullseye/main amd64 libctf-nobfd0 amd64 2.35.2-2 [110 kB]
#10 4.373 Get:7 http://deb.debian.org/debian bullseye/main amd64 libctf0 amd64 2.35.2-2 [53.2 kB]
#10 4.375 Get:8 http://deb.debian.org/debian bullseye/main amd64 binutils-x86-64-linux-gnu amd64 2.35.2-2 [1809 kB]
#10 4.433 Err:8 http://deb.debian.org/debian bullseye/main amd64 binutils-x86-64-linux-gnu amd64 2.35.2-2
#10 4.433   Hash Sum mismatch
#10 4.433   Hashes of expected file:
#10 4.433    - SHA256:b71ad0ec4328fd5da01fbd060714dafb1471d68dbfd2f897ad890b2ecf50b204
#10 4.433    - MD5Sum:4edcd39386fd29de7cc5c4e8f9630c10 [weak]
#10 4.433    - Filesize:1808556 [weak]
#10 4.433   Hashes of received file:
#10 4.433    - SHA256:0c9c737cd95ebc4af9f1f9906497550e9fd69015e070d6ee341940b85ebc4ca5
#10 4.433    - MD5Sum:172ad61245c2bfe954ad706430b9276d [weak]
#10 4.433    - Filesize:1808556 [weak]
#10 4.433   Last modification reported: Sat, 20 Feb 2021 20:42:12 +0000
#10 4.435 Err:9 http://deb.debian.org/debian bullseye/main amd64 binutils amd64 2.35.2-2
#10 4.435   Bad header line Bad header data [IP: 151.101.230.132 80]
#10 5.460 Get:10 http://deb.debian.org/debian bullseye/main amd64 libisl23 amd64 0.23-1 [676 kB]
#10 5.491 Get:11 http://deb.debian.org/debian bullseye/main amd64 libmpfr6 amd64 4.1.0-3 [2012 kB]
#10 5.526 Get:12 http://deb.debian.org/debian bullseye/main amd64 libmpc3 amd64 1.2.0-1 [45.0 kB]
#10 5.528 Get:13 http://deb.debian.org/debian bullseye/main amd64 cpp-10 amd64 10.2.1-6 [8528 kB]
#10 5.651 Err:13 http://deb.debian.org/debian bullseye/main amd64 cpp-10 amd64 10.2.1-6
#10 5.651   Hash Sum mismatch
#10 5.651   Hashes of expected file:
#10 5.651    - SHA256:ed2018b8c7ab7006826ccfcc6d306c3a5e1c6dc12595022e4e02913302fdc10e
#10 5.651    - MD5Sum:bbe743a9159e11df4d47a5c51afc75be [weak]
#10 5.651    - Filesize:8528068 [weak]
#10 5.651   Hashes of received file:
#10 5.651    - SHA256:9d3b2f21d0bbf846cc3dd07b5e06d6c5a5822dd1dcdd76819b5d2aa278d588a5
#10 5.651    - MD5Sum:ef024c63672660714f6aadf6cf76922f [weak]
#10 5.651    - Filesize:8528068 [weak]
#10 5.651   Last modification reported: Sun, 10 Jan 2021 21:57:15 +0000
#10 35.66 Get:14 http://deb.debian.org/debian bullseye/main amd64 cpp amd64 4:10.2.1-1 [19.7 kB]
#10 35.67 Get:15 http://deb.debian.org/debian bullseye/main amd64 fonts-dejavu-core all 2.37-2 [1069 kB]
#10 35.72 Get:16 http://deb.debian.org/debian bullseye/main amd64 fontconfig-config all 2.13.1-4.2 [281 kB]
#10 35.74 Get:17 http://deb.debian.org/debian bullseye/main amd64 libcc1-0 amd64 10.2.1-6 [47.0 kB]
#10 35.75 Get:18 http://deb.debian.org/debian bullseye/main amd64 libgomp1 amd64 10.2.1-6 [99.9 kB]
#10 35.76 Get:19 http://deb.debian.org/debian bullseye/main amd64 libitm1 amd64 10.2.1-6 [25.8 kB]
#10 35.76 Get:20 http://deb.debian.org/debian bullseye/main amd64 libatomic1 amd64 10.2.1-6 [9008 B]
#10 35.77 Get:21 http://deb.debian.org/debian bullseye/main amd64 libasan6 amd64 10.2.1-6 [2065 kB]
#10 35.82 Get:22 http://deb.debian.org/debian bullseye/main amd64 liblsan0 amd64 10.2.1-6 [828 kB]
#10 35.84 Get:23 http://deb.debian.org/debian bullseye/main amd64 libtsan0 amd64 10.2.1-6 [2000 kB]
#10 35.90 Get:24 http://deb.debian.org/debian bullseye/main amd64 libubsan1 amd64 10.2.1-6 [777 kB]
#10 35.92 Get:25 http://deb.debian.org/debian bullseye/main amd64 libquadmath0 amd64 10.2.1-6 [145 kB]
#10 35.93 Get:26 http://deb.debian.org/debian bullseye/main amd64 libgcc-10-dev amd64 10.2.1-6 [2328 kB]
#10 35.99 Get:27 http://deb.debian.org/debian bullseye/main amd64 gcc-10 amd64 10.2.1-6 [17.0 MB]
#10 36.27 Get:28 http://deb.debian.org/debian bullseye/main amd64 gcc amd64 4:10.2.1-1 [5192 B]
#10 36.28 Get:29 http://deb.debian.org/debian bullseye/main amd64 libbrotli1 amd64 1.0.9-2+b2 [279 kB]
#10 36.30 Get:30 http://deb.debian.org/debian bullseye/main amd64 libmd0 amd64 1.0.3-3 [28.0 kB]
#10 36.31 Get:31 http://deb.debian.org/debian bullseye/main amd64 libbsd0 amd64 0.11.3-1 [108 kB]
#10 36.32 Get:32 http://deb.debian.org/debian bullseye/main amd64 libc-dev-bin amd64 2.31-13+deb11u3 [275 kB]
#10 36.33 Get:33 http://deb.debian.org/debian bullseye/main amd64 libpng16-16 amd64 1.6.37-3 [294 kB]
#10 36.35 Get:34 http://deb.debian.org/debian bullseye/main amd64 libfreetype6 amd64 2.10.4+dfsg-1+deb11u1 [418 kB]
#10 36.36 Get:35 http://deb.debian.org/debian bullseye/main amd64 libfontconfig1 amd64 2.13.1-4.2 [347 kB]
#10 36.39 Get:36 http://deb.debian.org/debian bullseye/main amd64 libjpeg62-turbo amd64 1:2.0.6-4 [151 kB]
#10 36.40 Get:37 http://deb.debian.org/debian bullseye/main amd64 libdeflate0 amd64 1.7-1 [53.1 kB]
#10 36.41 Get:38 http://deb.debian.org/debian bullseye/main amd64 libjbig0 amd64 2.1-3.1+b2 [31.0 kB]
#10 36.42 Get:39 http://deb.debian.org/debian bullseye/main amd64 libwebp6 amd64 0.6.1-2.1 [258 kB]
#10 36.43 Get:40 http://deb.debian.org/debian bullseye/main amd64 libtiff5 amd64 4.2.0-1+deb11u1 [289 kB]
#10 36.45 Get:41 http://deb.debian.org/debian bullseye/main amd64 libxau6 amd64 1:1.0.9-1 [19.7 kB]
#10 36.46 Get:42 http://deb.debian.org/debian bullseye/main amd64 libxdmcp6 amd64 1:1.1.2-3 [26.3 kB]
#10 36.47 Get:43 http://deb.debian.org/debian bullseye/main amd64 libxcb1 amd64 1.14-3 [140 kB]
#10 36.48 Get:44 http://deb.debian.org/debian bullseye/main amd64 libx11-data all 2:1.7.2-1 [311 kB]
#10 36.50 Get:45 http://deb.debian.org/debian bullseye/main amd64 libx11-6 amd64 2:1.7.2-1 [772 kB]
#10 36.52 Get:46 http://deb.debian.org/debian bullseye/main amd64 libxpm4 amd64 1:3.5.12-1 [49.1 kB]
#10 36.53 Get:47 http://deb.debian.org/debian bullseye/main amd64 libgd3 amd64 2.3.0-2 [137 kB]
#10 36.54 Get:48 http://deb.debian.org/debian bullseye/main amd64 libc-devtools amd64 2.31-13+deb11u3 [245 kB]
#10 36.56 Get:49 http://deb.debian.org/debian bullseye/main amd64 linux-libc-dev amd64 5.10.127-1 [1516 kB]
#10 36.59 Get:50 http://deb.debian.org/debian bullseye/main amd64 libcrypt-dev amd64 1:4.4.18-4 [104 kB]
#10 36.60 Get:51 http://deb.debian.org/debian bullseye/main amd64 libtirpc-dev amd64 1.3.1-1 [190 kB]
#10 36.61 Get:52 http://deb.debian.org/debian bullseye/main amd64 libnsl-dev amd64 1.3.0-2 [66.4 kB]
#10 36.62 Get:53 http://deb.debian.org/debian bullseye/main amd64 libc6-dev amd64 2.31-13+deb11u3 [2348 kB]
#10 36.67 Get:54 http://deb.debian.org/debian bullseye/main amd64 mysql-common all 5.8+1.0.7 [7464 B]
#10 36.68 Get:55 http://deb.debian.org/debian bullseye/main amd64 mariadb-common all 1:10.5.15-0+deb11u1 [36.7 kB]
#10 36.69 Get:56 http://deb.debian.org/debian bullseye/main amd64 libmariadb3 amd64 1:10.5.15-0+deb11u1 [176 kB]
#10 36.70 Get:57 http://deb.debian.org/debian bullseye/main amd64 libssl-dev amd64 1.1.1n-0+deb11u3 [1814 kB]
#10 36.75 Get:58 http://deb.debian.org/debian bullseye/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2+deb11u1 [191 kB]
#10 36.76 Get:59 http://deb.debian.org/debian bullseye/main amd64 libmariadb-dev amd64 1:10.5.15-0+deb11u1 [185 kB]
#10 36.77 Get:60 http://deb.debian.org/debian bullseye/main amd64 manpages-dev all 5.10-1 [2309 kB]
#10 36.82 E: Fetched 57.4 MB in 33s (1760 kB/s)
#10 36.82 Failed to fetch http://deb.debian.org/debian/pool/main/b/binutils/binutils-x86-64-linux-gnu_2.35.2-2_amd64.deb  Hash Sum mismatch
#10 36.82    Hashes of expected file:
#10 36.82     - SHA256:b71ad0ec4328fd5da01fbd060714dafb1471d68dbfd2f897ad890b2ecf50b204
#10 36.82     - MD5Sum:4edcd39386fd29de7cc5c4e8f9630c10 [weak]
#10 36.82     - Filesize:1808556 [weak]
#10 36.82    Hashes of received file:
#10 36.82     - SHA256:0c9c737cd95ebc4af9f1f9906497550e9fd69015e070d6ee341940b85ebc4ca5
#10 36.82     - MD5Sum:172ad61245c2bfe954ad706430b9276d [weak]
#10 36.82     - Filesize:1808556 [weak]
#10 36.82    Last modification reported: Sat, 20 Feb 2021 20:42:12 +0000
#10 36.82 E: Failed to fetch http://deb.debian.org/debian/pool/main/b/binutils/binutils_2.35.2-2_amd64.deb  Bad header line Bad header data [IP: 151.101.230.132 80]
#10 36.82 E: Failed to fetch http://deb.debian.org/debian/pool/main/g/gcc-10/cpp-10_10.2.1-6_amd64.deb  Hash Sum mismatch
#10 36.82    Hashes of expected file:
#10 36.82     - SHA256:ed2018b8c7ab7006826ccfcc6d306c3a5e1c6dc12595022e4e02913302fdc10e
#10 36.82     - MD5Sum:bbe743a9159e11df4d47a5c51afc75be [weak]
#10 36.82     - Filesize:8528068 [weak]
#10 36.82    Hashes of received file:
#10 36.82     - SHA256:9d3b2f21d0bbf846cc3dd07b5e06d6c5a5822dd1dcdd76819b5d2aa278d588a5
#10 36.82     - MD5Sum:ef024c63672660714f6aadf6cf76922f [weak]
#10 36.82     - Filesize:8528068 [weak]
#10 36.82    Last modification reported: Sun, 10 Jan 2021 21:57:15 +0000
#10 36.82 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
------
executor failed running [/bin/sh -c apt-get update --fix-missing &&     apt-get -y install gcc libmariadb-dev]: exit code: 100
ERROR: Service 'app' failed to build : Build failed
docker-django % 
  • エラー内容の最後の方にあるオプション(--fix-missing)をつけて再実行してみるも結果は変わらず・・・
修正前Dockerfile
FROM python:3.9.13-slim

ENV PYTHONUNBUFFERED 1

RUN mkdir /workspace
WORKDIR /workspace

COPY requirements.txt /workspace/

### apt-getでエラーになる ###
RUN apt-get update --fix-missing && \
    apt-get -y install gcc libmariadb-dev
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip freeze

COPY . /workspace/

原因

  • 悪いプロキシで通信していた
修正後Dockerfile
python

FROM python:3.9.13-slim

ENV PYTHONUNBUFFERED 1

RUN mkdir /workspace
WORKDIR /workspace

COPY requirements.txt /workspace/

### 以下3行を追加 ###
RUN echo "Acquire::http::Pipeline-Depth 0;" >> /etc/apt/apt.conf.d/99fixbadproxy && \
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99fixbadproxy && \
echo "Acquire::BrokenProxy    true;" >> /etc/apt/apt.conf.d/99fixbadproxy
###################

RUN apt-get update --fix-missing && \
    apt-get -y install gcc libmariadb-dev
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip freeze


COPY . /workspace/

docker-compose up -d

  • コンテナが起動できた;;
# 中略
Creating docker-django_db_1 ... done
Creatning docker-django_app_1 ... done
Creating docker-django_web_1 ... done

参考にした記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0