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,260 points
879 views

1 answer to this question.

0 votes

Hi@akhtar,

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
47024ab1114f5c9979179071b60c5110acea82e8f45fd7789f84c0963658b528
[root@localhost ~]#

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

[root@localhost ~]# mysql -h 172.200.0.2 -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
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

answered Jul 29, 2020 by MD
• 95,460 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
12,685 views
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,230 points
2,188 views
+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 34,238 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,620 points
3,545 views
+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,460 points
581 views
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,460 points
2,431 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP