公式のmysql dockerイメージの使用

公式のmysql dockerイメージの使用

Dockerコンテナにmysql 5.7をインストールしようとすると、次のエラーが発生します。私はドッカーとコンテナを初めて使用します。

Step 16/23 : RUN apt-get install mysql-server-5.7
  ---> Running in 9624e9df68e7
 Reading package lists...
 Building dependency tree...
 Reading state information...
 Package mysql-server-5.7 is not available, but is referred to by another package.
 This may mean that the package is missing, has been obsoleted, or
 is only available from another source
 However the following packages replace it:
   mariadb-server-10.3
 E: Package 'mysql-server-5.7' has no installation candidate
 Service 'web' failed to build: The command '/bin/sh -c apt-get install mysql-server-5.7' returned a non-zero code: 100
 ERROR: Job failed: exit status 1

私のドッカーファイル:

FROM ubuntu:latest
RUN DEBIAN_FRONTEND=noninteractive
RUN apt-get upgrade
RUN apt-get update
RUN apt-get install -y wget 
RUN wget http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server-5.7_5.7.21-1ubuntu1_amd64.deb
RUN apt-get install -y nodejs
RUN apt-get install -y npm
RUN apt-get install -y prometheus

RUN apt-get install -y openjdk-8-jdk
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list' 
RUN apt-get update 
RUN apt-get install -y elasticsearch
RUN apt-get install -y mongodb
RUN apt-get install mysql-server-5.7
RUN mkdir -p -v /data/db
WORKDIR /home/ubuntu/Github-MICROSERVICE/
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 6001
CMD chown -R mysql:mysql /var/lib/mysql \
&& service mysql start \
&& mysql -ppassword -e "CREATE DATABASE IF NOT EXISTS ted;GRANT ALL PRIVILEGES on ted.* TO 'root'@'localhost' WITH GRANT OPTION; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';FLUSH PRIVILEGES;SET GLOBAL connect_timeout=28800;SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION';" \
&& service prometheus start \
&& service mongodb start\
&& npm start

ベストアンサー1

新しいバージョンのUbuntuに以前のバージョンのMysqlをインストールしようとしています。

FROM ubuntu:latest

現在(2020年8月)のubuntu:latestイメージタグはの同義語ですubuntu:20.04。これはUbuntuの新しいバージョンごとに変わります。 Mysql 5.7を含む最後のUbuntuバージョンはUbuntu 18.04でした。ねえhttps://packages.ubuntu.com/bionic/mysql-server-5.7

いくつかのオプションがあります。

公式のmysql dockerイメージの使用

自分のイメージをまったくスクロールする必要はないかもしれません。あなたの質問からは明確ではありません。mysql:5.7したがって、ドッカーイメージmysql:latest(8.0.21)を使用してコンテナを実行することもできます。

最新バージョンのmysqlを使用してください

dockerfileを次のように変更します。

apt-get install mysql-server

最新のUbuntuバージョンの最新のMysqlバージョンがインストールされます。

以前のバージョンのUbuntuの使用

ドッカーファイルを次のように変更します。

FROM ubuntu:1804

おすすめ記事