This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docker:mysql_phpmyadmin_link [2020/03/11 13:38] admin |
docker:mysql_phpmyadmin_link [2020/03/11 13:48] (current) admin |
||
---|---|---|---|
Line 59: | Line 59: | ||
Let's explain the options for the command docker run. | Let's explain the options for the command docker run. | ||
- | * The option --name allows us to assign a specific name for our running container. | + | * The option --name allows us to assign a specific name for our running container. |
- | * The option -e is used to pass a value for the container environment variable MYSQL_ROOT_PASSWORD. This variable is requested by the image to run properly and it will be assigned to the root password of MySQL. More information about this image can be found in docker hub (here). | + | * The option -e is used to pass a value for the container environment variable MYSQL_ROOT_PASSWORD. This variable is requested by the image to run properly and it will be assigned to the root password of MySQL. More information about this image can be found in docker hub (here). |
- | * The option -d means that docker will run the container in the background in “detached” mode. If -d is not used the container run in the default foreground mode. | + | * The option -d means that docker will run the container in the background in “detached” mode. If -d is not used the container run in the default foreground mode. |
- | * Finally, we need to indicate docker to use the image mysql:8.0.1 just downloaded, to run the container. | + | * Finally, we need to indicate docker to use the image mysql:8.0.1 just downloaded, to run the container. |
If everything went well you could see the running container by typing the following command: | If everything went well you could see the running container by typing the following command: | ||
+ | <code bash> | ||
$ docker ps -a | $ docker ps -a | ||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
d47128c8198c mysql:8.0.1 "docker-entrypoint.s…" 33 seconds ago Up 32 seconds 3306/tcp, 33060/tcp my-own-mysql | d47128c8198c mysql:8.0.1 "docker-entrypoint.s…" 33 seconds ago Up 32 seconds 3306/tcp, 33060/tcp my-own-mysql | ||
+ | </code> | ||
+ | |||
+ | ===== Step 2: Obtaining and running phpMyAdmin docker container ===== | ||
- | Step 2: Obtaining and running phpMyAdmin docker container | ||
Once the container running MySql server is working, the next step is configuring another container with phpMyAdmin. A quick search in docker hub by phpMyAdmin will show us a list of phpMyAdmin related images. In our case, we select the following one (https://hub.docker.com/r/phpmyadmin/phpmyadmin) which includes, not only an instance of phpMyAdmin, but also all components required by the app like a Nginx web server with PHP. | Once the container running MySql server is working, the next step is configuring another container with phpMyAdmin. A quick search in docker hub by phpMyAdmin will show us a list of phpMyAdmin related images. In our case, we select the following one (https://hub.docker.com/r/phpmyadmin/phpmyadmin) which includes, not only an instance of phpMyAdmin, but also all components required by the app like a Nginx web server with PHP. | ||
Line 76: | Line 79: | ||
To download the latest stable version of the image, open a terminal and type the following: | To download the latest stable version of the image, open a terminal and type the following: | ||
+ | <code bash> | ||
$ docker pull phpmyadmin/phpmyadmin:latest | $ docker pull phpmyadmin/phpmyadmin:latest | ||
+ | </code> | ||
After downloading the image, we need to run the container making sure that the container connects with the other container running mysql. In order to do so we type the following command: | After downloading the image, we need to run the container making sure that the container connects with the other container running mysql. In order to do so we type the following command: | ||
+ | <code bash> | ||
$ docker run --name my-own-phpmyadmin -d --link my-own-mysql:db -p 8081:80 phpmyadmin/phpmyadmin | $ docker run --name my-own-phpmyadmin -d --link my-own-mysql:db -p 8081:80 phpmyadmin/phpmyadmin | ||
+ | </code> | ||
Let’s explain the options for the command docker run. | Let’s explain the options for the command docker run. | ||
- | The options name and d has been explained in the previous section. | + | * The options name and d has been explained in the previous section. |
- | The option --link provides access to another container running in the host. In our case the container is the one created in the previous section, called my-own-mysql and the resource accessed is the MySQL db. | + | * The option --link provides access to another container running in the host. In our case the container is the one created in the previous section, called my-own-mysql and the resource accessed is the MySQL db. |
- | The mapping between the host ports and the container ports is done using the option -p followed by the port number of the host (8081) that will be redirected to the port number of the container (80, where the ngix server with the phpMyAdmin web app is installed). | + | * The mapping between the host ports and the container ports is done using the option -p followed by the port number of the host (8081) that will be redirected to the port number of the container (80, where the ngix server with the phpMyAdmin web app is installed). |
- | Finally, the docker run command needs the image used to create the container, so we will use the phpmyadmin image just pulled from docker hub. | + | * Finally, the docker run command needs the image used to create the container, so we will use the phpmyadmin image just pulled from docker hub. |
If everything went well you could see the running container by typing the following command: | If everything went well you could see the running container by typing the following command: | ||
+ | <code bash> | ||
$ docker ps -a | $ docker ps -a | ||
+ | </code> | ||
The terminal should displays something like: | The terminal should displays something like: | ||
- | Step 3: Access phpMyAdmin | + | |
+ | {{ :docker:docker_phpmyadmin_03.png?direct&800|}} | ||
+ | |||
+ | ===== Step 3: Access phpMyAdmin ===== | ||
Yes, that's all…everything is done! Easy right? You only need to open your favourite browser and type the following url: http://localhost:8081/ so your instance of phpMyAdmin will show up. To access, type root as username and the password you established in the step one when running the mysql container (if you followed the tutorial the password is mypass123). | Yes, that's all…everything is done! Easy right? You only need to open your favourite browser and type the following url: http://localhost:8081/ so your instance of phpMyAdmin will show up. To access, type root as username and the password you established in the step one when running the mysql container (if you followed the tutorial the password is mypass123). | ||
- | phpMyAdmin log in page | ||
- | phpMyAdmin main page | ||
- | Conclusion | ||
+ | {{ :docker:docker_phpmyadmin_01.png?direct&800 |}} | ||
+ | {{ :docker:docker_phpmyadmin_02.png?direct&800 |}} | ||
+ | |||
+ | ===== Conclusion ===== | ||
In this post we have demonstrated how easy can be to get your mysql + phpmyadmin platform up and running using docker. If you have any insight, comment or you think something is not right, I would really appreciate your feedback. Otherwise, I hope this tutorial helped you in getting started with docker. | In this post we have demonstrated how easy can be to get your mysql + phpmyadmin platform up and running using docker. If you have any insight, comment or you think something is not right, I would really appreciate your feedback. Otherwise, I hope this tutorial helped you in getting started with docker. |