{"id":327014,"date":"2021-08-18T15:36:38","date_gmt":"2021-08-18T12:36:38","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/"},"modified":"2021-08-18T15:36:38","modified_gmt":"2021-08-18T12:36:38","slug":"how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/","title":{"rendered":"#How to Run PHPMyAdmin in a Docker Container \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a29501bd4705\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a29501bd4705\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Basic_Usage\" >Basic Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Presetting_a_Server\" >Presetting a Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Using_a_MySQL_Docker_Container\" >Using a MySQL Docker Container<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Simplifying_Deployment_With_Docker_Compose\" >Simplifying Deployment With Docker Compose<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Configuring_the_Installation\" >Configuring the Installation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-run-phpmyadmin-in-a-docker-container-cloudsavvy-it\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Run PHPMyAdmin in a Docker Container \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-1386\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/08\/58f42558.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/08\/58f42558.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/08\/58f42558.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1565\" height=\"671\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.phpmyadmin.net\/en\/latest\/index.html\">PHPMyAdmin<\/a> is a popular administration interface for MySQL and MariaDB databases. It lets you interact with your schemas, tables, and data using a web browser.<\/p>\n<p>The project has an <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/hub.docker.com\/r\/phpmyadmin\/phpmyadmin\">official Docker image<\/a> which simplifies deployment in containerized environments. Here\u2019s how to use the image to quickly get a new PHPMyAdmin instance running.<\/p>\n<h2 id=\"basic-usage\"><span class=\"ez-toc-section\" id=\"Basic_Usage\"><\/span>Basic Usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The simplest installation lets a PHPMyAdmin container connect to any accessible database server:<\/p>\n<pre>docker run -d --name phpmyadmin -e PMA_ARBITRARY=1 -p 8080:80 phpmyadmin<\/pre>\n<p>This command starts PHPMyAdmin on port 8080. Visit <code>localhost:8080<\/code> in your browser to see the login screen. The presence of the <code>PMA_ARBITRARY<\/code> environment variable results in a server connection form being displayed. Specify the host and user credentials of your MySQL or MariaDB database to login.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13844\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/f560b0e3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1280\" height=\"648\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>When you\u2019re using this method, you\u2019ll normally see a PHPMyAdmin warning that \u201csome extended features have been deactivated.\u201d This occurs when the server you\u2019re connected to has no database called <code>phpmyadmin<\/code>. PHPMyAdmin uses this schema to store its own configuration data.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13846\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/08\/7ce52016.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1280\" height=\"648\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Follow the warning\u2019s link to \u201cCreate a database\u201d to complete the installation. Your user account will need permission to create new databases on the server.<\/p>\n<h2 id=\"presetting-a-server\"><span class=\"ez-toc-section\" id=\"Presetting_a_Server\"><\/span>Presetting a Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As an alternative to allowing arbitrary access, you can start the PHPMyAdmin container with a preconfigured server connection. Supply the <code>PMA_HOST<\/code> and <code>PMA_PORT<\/code> environment variables instead of <code>PMA_ARBITRARY<\/code>:<\/p>\n<pre>docker run -d --name phpmyadmin -e PMA_HOST=mysql.example.com -e PMA_PORT=33060 -p 8080:80 phpmyadmin<\/pre>\n<p><code>PMA_PORT<\/code> is optional. It will use the MySQL default of 3306 when no value is supplied.<\/p>\n<p>Starting the container with these variables will constrain PHPMyAdmin to working with the <code>mysql.example.com<\/code> server. You\u2019ll be prompted for a username and password on the login screen but you won\u2019t need to supply a hostname.<\/p>\n<p>PHPMyAdmin can also be configured to present multiple server options. Supply <code>PMA_HOSTS<\/code> and <code>PMA_PORTS<\/code> as comma-separated lists of connections to enable this functionality.<\/p>\n<h2 id=\"using-a-mysql-docker-container\"><span class=\"ez-toc-section\" id=\"Using_a_MySQL_Docker_Container\"><\/span>Using a MySQL Docker Container<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Another common use case is connecting to a MySQL or MariaDB server running in a separate Docker container. You can either expose the database server on a port or connect both containers to a shared Docker network. In either case, use the <code>PMA_HOST<\/code> and <code>PMA_PORT<\/code> environment variables will instruct PHPMyAdmin how to connect to the server.<\/p>\n<p>Legacy Docker links are also supported:<\/p>\n<pre>docker run -d --name phpmyadmin --link my_mysql_container:db -p 8080:80 phpmyadmin<\/pre>\n<p>This command lets you connect PHPMyAdmin to the <code>my_mysql_container<\/code> container without manually setting up networking links. This functionality is deprecated in Docker though so switching to the network commands is preferable:<\/p>\n<pre>docker network create phpmyadmin&#13;\ndocker network connect phpmyadmin mysql_container_name --ip 172.17.0.1&#13;\ndocker network connect phpmyadmin phpmyadmin_container_name<\/pre>\n<p>As an alternative, you can start PHPMyAdmin with a preconfigured network connection using Docker\u2019s <code>--network<\/code> flag:<\/p>\n<pre>docker run -d --name phpmyadmin --network phpmyadmin -p 8080:80 phpmyadmin<\/pre>\n<p>Now PHPMyAdmin will be able to reach the MySQL container via the shared network. Set the <code>PMA_HOST<\/code> environment variable to <code>172.17.0.1<\/code> when you start the container.<\/p>\n<h2 id=\"simplifying-deployment-with-docker-compose\"><span class=\"ez-toc-section\" id=\"Simplifying_Deployment_With_Docker_Compose\"><\/span>Simplifying Deployment With Docker Compose<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Writing a Docker Compose file simplifies non-trivial deployments. You can bring up a new PHPMyAdmin container in a repeatable fashion using the <code>docker-compose up -d<\/code> command.<\/p>\n<p>Here\u2019s a <code>docker-compose.yml<\/code> for PHPMyAdmin in arbitrary connection mode:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">version<\/span><span class=\"sy2\">: <\/span><span class=\"st0\">\"3\"<\/span>\n<span class=\"co4\">\nservices<\/span>:<span class=\"co4\">\n  phpmyadmin<\/span>:<span class=\"co3\">\n    image<\/span><span class=\"sy2\">: <\/span>phpmyadmin:latest<span class=\"co4\">\n    ports<\/span><span class=\"sy2\">:\n<\/span>        - 8080:80<span class=\"co4\">\n    environment<\/span><span class=\"sy2\">:\n<\/span>        - PMA_ARBITRARY=1<span class=\"co3\">\n    restart<\/span><span class=\"sy2\">: <\/span>unless-stopped<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Docker Compose also helps you create a stack with a fresh MySQL database installation and a PHPMyAdmin container:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">version<\/span><span class=\"sy2\">: <\/span><span class=\"st0\">\"3\"<\/span>\n<span class=\"co4\">\nservice<\/span>:<span class=\"co4\">\n  mysql<\/span>:<span class=\"co3\">\n    image<\/span><span class=\"sy2\">: <\/span>mysql:latest<span class=\"co4\">\n    expose<\/span><span class=\"sy2\">:\n<\/span>      - 3306<span class=\"co4\">\n    environment<\/span><span class=\"sy2\">:\n<\/span>      - MYSQL_ROOT_PASSWORD<span class=\"co4\">\n    volumes<\/span><span class=\"sy2\">:\n<\/span>      - mysql:\/var\/lib\/mysql<span class=\"co3\">\n    restart<\/span><span class=\"sy2\">: <\/span>unless-stopped<span class=\"co4\">\n  phpmyadmin<\/span>:<span class=\"co3\">\n    image<\/span><span class=\"sy2\">: <\/span>phpmyadmin:latest<span class=\"co4\">\n    ports<\/span><span class=\"sy2\">:\n<\/span>      - 8080:80<span class=\"co4\">\n    environment<\/span>:<span class=\"co3\">\n      - PMA_HOST<\/span><span class=\"sy2\">: <\/span>mysql<span class=\"co3\">\n      - PMA_PASSWORD<\/span><span class=\"sy2\">: <\/span>$<span class=\"br0\">{<\/span>MYSQL_ROOT_PASSWORD<span class=\"br0\">}<\/span><span class=\"co3\">\n    restart<\/span><span class=\"sy2\">: <\/span>unless-stopped\n<span class=\"co4\">\nvolumes<\/span><span class=\"sy2\">:\n<\/span>  - mysql<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Run <code>docker-compose up -d<\/code> to bring up MySQL with a fully networked PHPMyAdmin container. PHPMyAdmin\u2019s <code>PMA_HOST<\/code> variable is set to <code>mysql<\/code>, referencing the MySQL service name. Docker Compose automatically sets hostnames to match service names, allowing PHPMyAdmin to connect to MySQL using the shared network.<\/p>\n<h2 id=\"configuring-the-installation\"><span class=\"ez-toc-section\" id=\"Configuring_the_Installation\"><\/span>Configuring the Installation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>THe PHPMyAdmin Docker image supports a user-supplied configuration file that you can inject via a Docker volume. The path is <code>\/etc\/phpmyadmin\/config.user.inc.php<\/code>:<\/p>\n<pre>docker run -d &#13;\n    --name phpmyadmin &#13;\n    -e PMA_ARBITRARY=1 &#13;\n    -p 8080:80 &#13;\n    -v my-config-file.php:\/etc\/phpmyadmin\/config.user.inc.php&#13;\n    phpmyadmin<\/pre>\n<p>You can add any of the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.phpmyadmin.net\/en\/latest\/config.html#config\">configuration variables<\/a> supported by PHPMyAdmin.<\/p>\n<p>The image also supports <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/hub.docker.com\/r\/phpmyadmin\/phpmyadmin#environment-variables-summary\">environment variables<\/a> for many common settings. These include <code>MEMORY_LIMIT<\/code>, <code>UPLOAD_LIMIT<\/code> and <code>MAX_EXECUTION_TIME<\/code>, each of which correspond to PHP INI values that might need to be adjusted if you\u2019re using long-running or complicated queries.<\/p>\n<p>Sensitive values, such as <code>PMA_HOST<\/code>, <code>PMA_PASSWORD<\/code>, and <code>MYSQL_ROOT_PASSWORD<\/code>, can be injected using Docker secrets instead of plain environment variables. <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">App<\/a>end <code>_FILE<\/code> to the variable\u2019s name, then set the value to a path inside the container that provides the actual value.<\/p>\n<pre>docker run -d --name phpmyadmin -e PMA_HOST_FILE=\/run\/secrets\/pma_host -p 8080:80 phpmyadmin<\/pre>\n<h2 id=\"summary\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>PHPMyAdmin is one of the most popular and best known MySQL administration utilities. Bare-metal installation adds several dependencies to your system, bundling Apache and PHP alongside the app\u2019s source code.<\/p>\n<p>Installing PHPMyAdmin in Docker gives you an isolated environment that can be created, replaced, and deleted using a handful of Docker CLI commands. The official image can connect to any MySQL server that\u2019s accessible from your host, including databases running in other Docker containers.<\/p>\n<p>More detailed guidance on running and using PHPMyAdmin can be found in the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.phpmyadmin.net\/en\/latest\/setup.html\">official documentation<\/a>. It\u2019s particularly important to review the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.phpmyadmin.net\/en\/latest\/setup.html#securing-your-phpmyadmin-installation\">security guide<\/a> so you don\u2019t unintentionally leave your database at risk of external attack. You should also consider Docker security best practices when deploying PHPMyAdmin inside a container that\u2019s exposed to the outside world.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/13842\/how-to-run-phpmyadmin-in-a-docker-container\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Run PHPMyAdmin in a Docker Container \u2013 CloudSavvy IT&#8221; PHPMyAdmin is a popular administration interface for MySQL and MariaDB databases. It lets you interact with your schemas, tables, and data using a web browser. The project has an official Docker image which simplifies deployment in containerized environments. Here\u2019s how to use the image&#8230;<\/p>\n","protected":false},"author":1,"featured_media":327015,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/08\/58f42558.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-327014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/327014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=327014"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/327014\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/327015"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=327014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=327014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=327014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}