0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MySQL8.4をDockerにインストールする手順

Last updated at Posted at 2025-12-27

下記を参考

前提

作成者の環境

1 2
OS Windows 11
Docker 27.1.1

手順

プロジェクト構成は下記で進めます

project/
├── docker-compose.yml
└── mysql/
    └── Dockerfile

使用イメージについて

MySQLの公式ドキュメントで紹介されているイメージ(Oracle Container Registry)とDocker Hubのイメージは取得元が異なりますが、本手順ではDocker Hubのイメージを使用します

  • Docker Hubのドキュメントの方が分かりやすい
  • 利用者が多い(10億回以上ダウンロード)
  • MySQL公式チームがメンテナンスしている

Dockerfileを作成

FROM mysql:8.4.0

Docker HubからMySQL 8.4のイメージを取得します

docker-compose.ymlを作成

services:
  mysql:
    build: ./mysql
    restart: always
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: password

restart: alwaysについて

こちらの設定はいれてくとよさそうです

  • コンテナが停止したら常に再起動
  • ただし手動で停止した場合は、Dockerデーモンが再起動するか、コンテナを手動で再起動するまで再起動しない

Start containers automatically | Docker Docs
https://docs.docker.com/engine/containers/start-containers-automatically/

コンテナの起動

プロジェクトフォルダで以下のコマンドを実行してください

(事前にDocker Desktop を起動してください)

docker compose up -d

コンテナ起動後に確認

docker compose exec mysql bash
bash-5.1# mysql --version
mysql  Ver 8.4.0 for Linux on x86_64 (MySQL Community Server - GPL)
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?