MOCKSTACKS
EN
Questions And Answers

More Tutorials









MYSQL Install container with Docker Compose

Simple example with docker-compose


This is an simple example to create a mysql server with docker

1.- create docker-compose.yml:


Note:

If you want to use same container for all your projects, you should create a PATH in your HOME_PATH. If you want to create it for every project you could create a docker directory in your project.

version: '2'
services:
 cabin_db:
 image: mysql:latest
 volumes:
 - "./.mysql-data/db:/var/lib/mysql"
 restart: always
 ports:
 - 3306:3306
 environment:
 MYSQL_ROOT_PASSWORD: rootpw
 MYSQL_DATABASE: cabin
 MYSQL_USER: cabin
 MYSQL_PASSWORD: cabinpw

2.- run it:


cd PATH_TO_DOCKER-COMPOSE.YML
docker-compose up -d

3.- connect to server


mysql -h 127.0.0.1 -u root -P 3306 -p rootpw
Hurray!!

4.- stop server


docker-compose stop


Conclusion

In this page (written and validated by ) you learned about MYSQL Install container with Docker Compose . What's Next? If you are interested in completing MYSQL tutorial, your next topic will be learning about: MYSQL Character Sets and Collations.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.