You can list the available images by executing:
docker search mysql
and download it with:
docker pull mysql
If you want to list your local images, just type:
docker images
Now in order to create the container we can execute a command with the following options:
docker run -p <port>:<port> --name <container-name> -v <local-folder>:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=<root-password> -d mysql:<tag>
where:
-p | Publish a container’s port(s) to the host |
--name | Assign a name to the container |
-v | Bind mount a volume |
-e | Sets the MYSQL_ROOT_PASSWORD environment variable |
-d | Run container in background and print container ID |
tag | Tag specifying the MySQL version you want. |
Then if you want to see the containers currently running:
docker ps
But, How can I start working with the MySQL of the docker container?
Via terminal (accessing the container bash):
docker exec -it <container-name> bash
Or just pointing your favorite Database Client to the container configuration: