How to launch a Docker container for MySQL

0 votes

Hi Guys,

I have configured Docker Engine in my Linux system. I want to launch one container for the MySQL database. How can I do that?

Jul 29, 2020 in Docker by akhtar
• 38,210 points

1 answer to this question.

0 votes


You can download MySQL image from the docker hub. But you need to check the document properly as MySQL database needs some environment variable. You can follow the below-given example.

[root@localhost ~]#  docker run -dit -e MYSQL_ROOT_PASSWORD=redhat -e MYSQL_USER=nadim -e MYSQL_PASSWORD=redhat -e MYSQL_DATABASE=mydatabase mysql:5.7
[root@localhost ~]#

To connect to the database your system should have MySQL command.

[root@localhost ~]# mysql -h -u nadim -predhat
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

answered Jul 29, 2020 by MD
• 95,300 points

Related Questions In Docker

+1 vote
7 answers

How to connect to a Docker container running mysql on Windows 10?

Avoid using bind_address in your my.cnf file. I don't ...READ MORE

answered Apr 25, 2019 in Docker by Haseeb
0 votes
1 answer

How to disable networking stack for a docker container?

If you want to completely disable the ...READ MORE

answered Jul 4, 2019 in Docker by Sirajul
• 59,090 points
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 24,272 views
0 votes
1 answer

How to run a docker command from inside the container?

You must have come across the /var/run/docker.sock file, ...READ MORE

answered Jun 28, 2018 in Docker by Sophie may
• 10,550 points
+2 votes
1 answer
0 votes
2 answers
0 votes
1 answer

How to launch one Docker Container for ElasticSearch Engine?

Hi@akhtar, You can use ElasticSearch image that is ...READ MORE

answered Jun 16, 2020 in Docker by MD
• 95,300 points
0 votes
1 answer

How to launch one Docker container for Logstash?

Hi@akhtar, You can find one Docker image for ...READ MORE

answered Jun 17, 2020 in Docker by MD
• 95,300 points