It's time to install DB with Docker! DB installation for beginners on Docker

About this article

** Database **, I think it will almost certainly be used in enterprise and other application development even in 2020. However, as in the past, there are still many people who do their best to manually install the production environment, verification environment, and development environment directly on the host OS.

(Maybe it's a little overstated) ** It's a waste of time to spend more than 5 minutes installing the database in your development environment! ** **

Now, remember that you can quickly install DB with Docker at this time. However, if you need to ensure redundancy or availability, such as in a production environment, use an installation method that meets your requirements.

Oracle Database on Docker

SQL Server on Docker

--[Docker Hub --Microsoft SQL Server] dockerrepo-mssql(Ubuntu base)

Please create docker-compose.yaml by referring to this [repository] github-docker-mssql published on GitHub.

docker-compose.yaml


version: '3'

services:
  mssql:
    image: mcr.microsoft.com/mssql/rhel/server:2019-latest
    container_name: 'mssql2019-latest-rhel'
    environment:
      - MSSQL_SA_PASSWORD=<your_strong_password>
      - ACCEPT_EULA=Y
      # - MSSQL_PID=<your_product_id> # default: Developer
      # - MSSQL_PID=Express
      # - MSSQL_PID=Standard
      # - MSSQL_PID=Enterprise
      # - MSSQL_PID=EnterpriseCore
    ports:
      - 1433:1433
    # volumes: # Mounting a volume does not work on Docker for Mac
    #   - ./mssql/log:/var/opt/mssql/log
    #   - ./mssql/data:/var/opt/mssql/data

Start the container with docker-compose up -d and the SQL Server installation is complete.

docker-compose up -d

MySQL on Docker

Please create docker-compose.yaml by referring to this [repository] github-docker-mysql published on GitHub.

docker-compose.yaml


version: '3'

services:
  db:
    image: mysql:8
    container_name: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: P@ssw0rd #required
      # MYSQL_DATABASE: employees #optional
      # MYSQL_USER: user #optional
      # MYSQL_PASSWORD: P@ssw0rd #optional
      # MYSQL_ALLOW_EMPTY_PASSWORD: "yes" #optional
      # MYSQL_RANDOM_ROOT_PASSWORD: "yes" #optional
      # MYSQL_ONETIME_PASSWORD: "yes" #optional (MySQL 5.6 or above)
      # MYSQL_INITDB_SKIP_TZINFO: "" #optional
    ports:
        - 3306:3306
    volumes:
        - ./data/mysql:/var/lib/mysql
        - ./conf:/etc/mysql/conf.d

Start the container with docker-compose up -d and the MySQL installation is complete.

docker-compose up -d

PostgreSQL on Docker

Please create docker-compose.yaml by referring to this [repository] github-docker-postgres published on GitHub.

docker-compose.yaml


version: '3'

services:
  db:
    image: postgres:13
    container_name: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: P@ssw0rd #required
      # POSTGRES_USER: postgres #optional
      # POSTGRES_DB: postgres #optional
      # POSTGRES_INITDB_ARGS: "--data-checksums" #optional
      # POSTGRES_INITDB_WALDIR: "" #optional (PostgreSQL 10+ or above)
      # POSTGRES_INITDB_XLOGDIR: "" #optional (PostgreSQL 9.x only)
      # POSTGRES_HOST_AUTH_METHOD: trust #optional
      # PGDATA: /var/lib/postgresql/data/pgdata #optional
    ports:
        - 5432:5432
    volumes:
      - ./data:/var/lib/postgresql/data

Start the container with docker-compose up -d and the PostgreSQL installation is complete.

docker-compose up -d

MongoDB on Docker

Please create docker-compose.yaml by referring to this [repository] github-docker-mongodb published on GitHub.

docker-compose.yaml


version: '3'

services:
  mongo:
    image: mongo:latest
    container_name: mongodb
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: P@ssw0rd
    ports:
        - 27017:27017
    volumes:
        - ./data/db:/data/db
        - ./data/configdb:/data/configdb
    # Command 1: Customize configuration without configuration file
    # Command 2: Setting WiredTiger cache size limits
    # command: >
    #   --serviceExecutor adaptive
    #   --wiredTigerCacheSizeGB 1.5

  mongo-express:
    image: mongo-express:latest
    container_name: mongo-express
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: P@ssw0rd

Start the container with docker-compose up -d and the MongoDB installation is complete.

docker-compose up -d

Management tools

As for the management tool, you can use whatever you like, but the recommended method is to use ** Visual Studio Code **. It's very convenient because you can do both Docker Compose and DB operations within Visual Studio Code. Please refer to the following article for details.

--[Convenient extension for working with SQL Database on Visual Studio Code] vscode-mssql -[Convenient extension for working with MySQL on Visual Studio Code] vscode-mysql --[Convenient extension for working with PostgreSQL and Cosmos DB on Visual Studio Code] vscode-postgres --[Convenient extension for working with MongoDB on Visual Studio Code] vscode-mongodb

Also, I think it would be ant to create the adminer container described in MySQL and PostgreSQL together.

Reference information

Oracle Database

SQL Server

MySQL

PostgresSQL

MongoDB


Recommended Posts

It's time to install DB with Docker! DB installation for beginners on Docker
How to install python3 with docker centos
It's time to stop generating SMILES with RDKit
nvidia-docker2 installation guide for using gpu with docker
How to install OpenGM on OSX with macports
It's okay to stumble on Titanic! Introducing the Kaggle strategy for super beginners
Install docker on Fedora31
How to install caffe on OS X with macports
Output log to console with Flask + Nginx on Docker
Install Docker on AWS
Install Python 3.6 on Docker
How to install nkf with rpm file on Red Hat Enterprise Linux 7.7 (for non-internet environment)
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
[For beginners] How to use for statements on Linux (variables, etc.)
A study method for beginners to learn time series analysis
From environment construction to deployment for flask + Heroku with Docker
For beginners, how to deal with common errors in keras
How to install Theano on Mac OS X with homebrew
Install Docker on WSL Ubuntu 18.04
~ Tips for beginners to Python ③ ~
For those of you who don't know how to set a password with Jupyter on Docker
Easy-to-understand explanation of Python Web application (Django) even for beginners (5) [Introduction to DB operation with Django shell]
Dealing with PermissionError [Error 1] for pip install -U pip on macOS Sierra
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
For the time being, I want to convert files with ffmpeg !!
From ubuntu installation to running kinect with docker and ros (overview)
[Small story] I can't find it even though I apt search to install Python on ubuntu with Docker.
Steps to install MySQL 8.0 on CentOS 8.1
raspberry pi 4 centos7 install on docker
How to install mysql-connector-python on mac
Steps to install matplotlib on Mac
Tips for running Go with docker
How to install python-pip with ubuntu20.04LTS
Steps to install VirtualBox on CentOS
How to install graph-tool on macOS
How to install VMware-Tools on Linux
How to install OpenCV on Mac
How to install TensorFlow on CentOS 7
Unable to install Python with pyenv
Install pyStruct on MacOSX10.11 with macports
Install confluent-kafka for Python on Ubuntu
How to install mysql-connector with pip3
How to install Maven on CentOS
Steps to install python3 on mac
Install python2.x on catalina with pyenv
How to install Go on Ubuntu
How to install music 21 on windows
LSTM (1) for time series forecasting (for beginners)
How to install Anaconda with pyenv
Save json data received by mosquitto on docker to db and Elasticsearch
Use Docker Desktop for Windows to start the latest odo with 2 commands
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
Install ROS and ROS module for Roomba on RaspberryPi3 and try to run it
I tried to draw a system configuration diagram with Diagrams on Docker
I tried to install Docker on Windows 10 Home but it didn't work
Links for handling jupyter notebooks on Docker on Ubuntu on VirtualBox on macOS with SSH
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
Error due to UnicodeDecodeError when reading CSV file with Python [For beginners]
Try to poke DB on IBM i with python + JDBC using JayDeBeApi