It is not necessary for the host port to be 3306, it can be anything that is available to be used. MySQL will listen at port 3306 so we are mapping ports ( 3306 → 3306) from your host machine to the docker container. If you are not specifying this flag, docker will assign some randomly generated names. name → To give a name to your container. Let’s break down the above command and see what each flag does. Run the following command to spin up the MySQL docker container: $ docker run -name mysql -p 3306:3306 -v mysql_volume:/var/lib/mysql/ -d -e "MYSQL_ROOT_PASSWORD=temp123" mysql You can also skip this step and run the " docker run" command as shown in the next section which will pull the image if not available locally. Now the image is ready to spin up the container. ![]() Mysql latest b05128b000dd 12 days ago 516MB Sample output: REPOSITORY TAG IMAGE ID CREATED SIZE To check if the image is available locally, you can run the following command: $ docker images mysql Heads Up: It is not necessary to use the tag " latest", by default it will pull the latest image. Run the following command to pull the MySQL image from the docker hub to your machine. The important thing is you have to decide what version of MySQL you are going to run. Go to the Docker Hub to get the MySQL docker image. $ docker -versionĭocker version 20.10.11, build dea9396 $ docker-compose -versionĭocker-compose version 1.29.2, build unknown 2. You can run the following commands to check the docker and docker-compose versions you are running with. ![]() You can also refer the official Docker documentation links given below to know how to setup Docker and Docker compose. If you have not installed docker and docker-compose, refer the following guides: Connect to MySQL Database Using MySQL Workbenchīefore spinning up the MySQL docker container, you need to have docker and docker-compose installed in your machine. Setup MySQL Container Using Docker-Compose
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |