Docker MySQL, PostgreSQL, and MongoDB

Docker MySQL, PostgreSQL, and MongoDB

Learn how to use Docker to install MySQL, PostgreSQL, and MongoDB

Introduction

In this short tutorial, you will learn how to install MySQL, PostgreSQL, and MongoDB using Docker. If you do not have Docker installed you can down it here.

MySQL

Run the following command to install the latest version of MySQL:

docker container run -p 3306:3306 --name mysql-example \ 
-v /path/local/host:/var/lib/mysql 
-e MYSQL_ROOT_PASSWORD=0123456789 -d mysql

PostgreSQL

Run the following command to install the latest version of PostgreSQL:

docker container run -d -p 5432:5432 --name pg-example \
-v /path/on/host:/var/lib/postgresql/data 
-e POSTGRES_DB=databaseName -e POSTGRES_PASSWORD=0123456789 postgres

MongoDB

Run the following command to install the latest version of MongoDB:

docker container run --name mongodb-example 
-v /path/local/host:/data/db 
-d -p 27017:27017 mongo

Conclusion

In this short tutorial, you learned how to install three different databases using Docker.

Did you like it? Why don't you try also...

Quickly Spin Up PostgreSQL With Docker Compose

Quickly Spin Up PostgreSQL With Docker Compose

Learn How to Install PostgreSQL Using Docker Compose

Quickly Spin Up MongoDB With Docker Compose

Quickly Spin Up MongoDB With Docker Compose

Learn How to Install MongoDB Using Docker Compose

Quickly Spin Up MariaDB With Docker Compose

Quickly Spin Up MariaDB With Docker Compose

Learn How to Install MariaDB Using Docker Compose