How to do it…

Execute the docker run command to create and run a MySQL Docker container from the mysql:latest image, assigning the container name as mysql-container using the --name flag, as follows:

$ docker run --net=my-bridge-network -p 3306:3306 --name mysql-container -e MYSQL_ROOT_PASSWORD=my-pass -d mysql:latest
c3ca3e6f253efa40b1e691023155ab3f37eb07b767b1744266ac4ae85fca1722

The --net flag specified in the docker run command connects mysql-container to my-bridge-network. The -p flag specified in the docker run command publishes the container's 3306 port to the host 3306 port. The -e flag specified in the docker run command sets the MYSQL_ROOT_PASSWORD value as my-pass, which is an environment variable of the mysql:latest image. The -d flag specified in the docker run command starts the container in a daemon mode, and the hash string at the end represents the ID of the mysql-container.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.28.108