{"id":3744,"date":"2017-06-13T07:15:01","date_gmt":"2017-06-13T14:15:01","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=3744"},"modified":"2025-06-13T21:28:57","modified_gmt":"2025-06-14T04:28:57","slug":"deploy-php-couchbase-application-docker-containers","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/","title":{"rendered":"Deploy a PHP with Couchbase Application as Docker Containers"},"content":{"rendered":"<p>Earlier in the year I wrote about containerizing applications written in various development technologies that communicate with Couchbase Server. For example, I had written about deploying a <a href=\"https:\/\/www.couchbase.com\/blog\/deploy-golang-web-application-couchbase-docker-containers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Golang application with Docker<\/a>, a <a href=\"https:\/\/www.couchbase.com\/blog\/docker-deploy-containerized-java-couchbase-web-application\/\" target=\"_blank\" rel=\"noopener noreferrer\">Java application with Docker<\/a>, and a <a href=\"https:\/\/www.couchbase.com\/blog\/deploy-node-js-couchbase-web-application-docker-containers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Node.js application with Docker<\/a>. This time around we&#8217;re going to take a look at how to deploy a PHP container that communicates with a Couchbase Server container.<\/p>\n<p>We&#8217;re going to create an automatically provisioned Couchbase node and simplistic PHP application that writes and reads data from the Couchbase NoSQL node.<\/p>\n<p><!--more--><\/p>\n<p>Let&#8217;s first define the project structure that will represent both containers:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">root\r\n-- couchbase\r\n-- -- configure.sh\r\n-- -- Dockerfile\r\n-- php\r\n-- -- application\r\n-- -- -- index.php\r\n-- -- configuration\r\n-- -- -- php.ini\r\n-- -- Dockerfile\r\n-- docker-compose.yml<\/pre>\n<p>Each container will have its own\u00a0<code><\/code><strong>Dockerfile<\/strong> which will contain blueprint information for our setup. The\u00a0<strong>docker-compose.yml<\/strong> file will build and deploy the containers using defined port and environment variable information.<\/p>\n<h2>Containerizing the PHP Application<\/h2>\n<p>Since this is a PHP tutorial, we&#8217;ll start by building our simple PHP application and containerizing it. Because we want to automate the deployment, we&#8217;ll be developing our\u00a0<strong>php.ini<\/strong> file locally and copying it over during the build process.<\/p>\n<p>Before we get to that part, let&#8217;s add some code to the\u00a0<strong>index.php<\/strong> file:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">&lt;?php\r\n\r\n    header(\"Content-Type: application\/json\");\r\n\r\n    $cluster = new CouchbaseCluster(\"couchbase:\/\/\" . getenv(\"COUCHBASE_HOST\"));\r\n    $bucket = $cluster-&gt;openBucket(getenv(\"COUCHBASE_BUCKET_NAME\"), getenv(\"COUCHBASE_BUCKET_PASSWORD\"));\r\n\r\n    try {\r\n        $result = $bucket-&gt;get(\"nraboy\");\r\n    } catch (CouchbaseException $e) {\r\n        $bucket-&gt;insert(\"nraboy\", array(\r\n            \"name\" =&gt; \"Nic Raboy\",\r\n            \"social_media\" =&gt; array(\r\n                \"twitter\" =&gt; \"https:\/\/www.twitter.com\/nraboy\",\r\n                \"website\" =&gt; \"https:\/\/www.thepolyglotdeveloper.com\"\r\n            )\r\n        ));\r\n        $result = $bucket-&gt;get(\"nraboy\");\r\n    }\r\n    echo json_encode($result-&gt;value);\r\n\r\n?&gt;<\/pre>\n<p>In the above code we&#8217;re saying that any data printed will be JSON format. We&#8217;re establishing a connection to a Couchbase cluster and opening a particular Bucket in that cluster. The catch here is that we&#8217;re using environment variables to define the cluster and Bucket. These will be set in the deployment process.<\/p>\n<p>With the application connected, it will try to get a document from Couchbase by key. If that document doesn&#8217;t exist, it will be created and then obtained. The obtained document will be printed as a result.<\/p>\n<p>Like I mentioned earlier, this is a simple application, nothing fancy. Now we can focus on the Docker aspect of this application.<\/p>\n<p>Open the\u00a0<strong>Dockerfile<\/strong> and include the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">FROM php:5.6.30-apache\r\n\r\nRUN apt-get update\r\nRUN apt-get install -y wget lsb-release\r\nRUN wget https:\/\/packages.couchbase.com\/releases\/couchbase-release\/couchbase-release-1.0-2-amd64.deb\r\nRUN dpkg -i couchbase-release-1.0-2-amd64.deb\r\nRUN rm couchbase-release-1.0-2-amd64.deb\r\nRUN apt-get update\r\nRUN apt-get install -y libcouchbase-dev build-essential php5-dev zlib1g-dev\r\nRUN pecl install pcs-1.3.3\r\nRUN pecl install couchbase\r\n\r\nWORKDIR \/var\/www\/html\r\n\r\nCOPY .\/configuration\/php.ini \/usr\/local\/etc\/php\/\r\nCOPY .\/application\/ \/var\/www\/html\/\r\n\r\nRUN chown www-data:www-data . -R<\/pre>\n<p>The above says that we&#8217;re going to be using an Apache image. If you&#8217;ve ever used Couchbase with PHP, what comes next will look very familiar. All the dependency gather was taken straight from the <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/sdk\/php\/start-using-sdk.html\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase PHP documentation<\/a>. The\u00a0<code>RUN<\/code> command means that the dependencies will be gathered at build time, not run time.<\/p>\n<p>With the dependencies available, the\u00a0<strong>php.ini<\/strong> file is copied into the image as well as the\u00a0<strong>index.php<\/strong> file. This brings us to the\u00a0<strong>php.ini<\/strong> file.<\/p>\n<p>Instead of pasting a long and nasty chunk of configuration, it is best you just download the\u00a0<strong>php.ini<\/strong> file from the official <a href=\"https:\/\/github.com\/php\/php-src\/blob\/master\/php.ini-production\" target=\"_blank\" rel=\"noopener noreferrer\">PHP GitHub repository<\/a>. The only change we&#8217;re making is in regards to the extensions. Per the <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/sdk\/php\/start-using-sdk.html\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase PHP documentation<\/a>, we need to add the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">extension=couchbase.so<\/pre>\n<p>Find the extensions section and add it there.<\/p>\n<p>At this point the PHP image can be built and we can deploy it as a container. However, we&#8217;re going to plan ahead and create a Compose file.<\/p>\n<p>Open the\u00a0<strong>docker-compose.yml<\/strong> file and include the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">version: '2'\r\n\r\nservices:\r\n\r\n    php:\r\n        build: .\/php\r\n        ports:\r\n            - 8080:80\r\n        environment:\r\n            - COUCHBASE_HOST=couchbase\r\n            - COUCHBASE_BUCKET_NAME=default\r\n            - COUCHBASE_BUCKET_PASSWORD=\r\n        restart: always<\/pre>\n<p>The above defines a service called\u00a0<code>php<\/code> with port mappings and environment variables. These variables match what we have in the PHP application. The image will be built from the\u00a0<strong>Dockerfile<\/strong> found in the PHP project.<\/p>\n<p>If you set the\u00a0<code>COUCHBASE_HOST<\/code> to something remote, we&#8217;re good to go, but for this example we&#8217;re going to use another container.<\/p>\n<h2>Containerizing Couchbase Server<\/h2>\n<p>The goal in containerizing Couchbase is that we&#8217;ll be automating it. There already exists a Docker image for Couchbase, but it isn&#8217;t pre-provisioned which can take time during a deployment process.<\/p>\n<p>Open the\u00a0<strong>Dockerfile<\/strong> file the Couchbase project and include the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">FROM couchbase\r\n\r\nCOPY configure.sh \/opt\/couchbase\r\n\r\nCMD [\"\/opt\/couchbase\/configure.sh\"]<\/pre>\n<p>The above says that we&#8217;re going to use the official Couchbase image, but we&#8217;re going to copy a script into it and then run it at runtime. This script will provision the instance automatically.<\/p>\n<p>Open the\u00a0<strong>configure.sh<\/strong> file and include the following commands:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">set -m\r\n\r\n\/entrypoint.sh couchbase-server &amp;\r\n\r\nsleep 15\r\n\r\ncurl -v -X POST https:\/\/127.0.0.1:8091\/pools\/default -d memoryQuota=512 -d indexMemoryQuota=512\r\n\r\ncurl -v https:\/\/127.0.0.1:8091\/node\/controller\/setupServices -d services=kv%2cn1ql%2Cindex\r\n\r\ncurl -v https:\/\/127.0.0.1:8091\/settings\/web -d port=8091 -d username=$COUCHBASE_ADMINISTRATOR_USERNAME -d password=$COUCHBASE_ADMINISTRATOR_PASSWORD\r\n\r\ncurl -i -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST https:\/\/127.0.0.1:8091\/settings\/indexes -d 'storageMode=memory_optimized'\r\n\r\ncurl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST https:\/\/127.0.0.1:8091\/pools\/default\/buckets -d name=$COUCHBASE_BUCKET -d bucketType=couchbase -d ramQuotaMB=128 -d authType=sasl -d saslPassword=$COUCHBASE_BUCKET_PASSWORD\r\n\r\nsleep 15\r\n\r\ncurl -v https:\/\/127.0.0.1:8093\/query\/service -d \"statement=CREATE PRIMARY INDEX ON `$COUCHBASE_BUCKET`\"\r\n\r\nfg 1<\/pre>\n<p>Couchbase Server has its own RESTful API which we&#8217;re trying to consume with a bunch of cURL commands. We are defining memory quotas, which services exist in the node, and authentication information.<\/p>\n<p>Notice that many of the commands include environmental variables like\u00a0<code>$COUCHBASE_ADMINISTRATOR_USERNAME<\/code>. This is because we&#8217;re going to pass them in via the\u00a0<strong>docker-compose.yml<\/strong> file just like we did with the PHP application.<\/p>\n<p>Open the\u00a0<strong>docker-compose.yml<\/strong> file and make it look like the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">version: '2'\r\n\r\nservices:\r\n\r\n    couchbase:\r\n        build: .\/couchbase\r\n        ports:\r\n            - 8091:8091\r\n            - 8092:8092\r\n            - 8093:8093\r\n        environment:\r\n            - COUCHBASE_ADMINISTRATOR_USERNAME=Administrator\r\n            - COUCHBASE_ADMINISTRATOR_PASSWORD=password\r\n            - COUCHBASE_BUCKET=default\r\n            - COUCHBASE_BUCKET_PASSWORD=\r\n\r\n    php:\r\n        build: .\/php\r\n        ports:\r\n            - 8080:80\r\n        environment:\r\n            - COUCHBASE_HOST=couchbase\r\n            - COUCHBASE_BUCKET_NAME=default\r\n            - COUCHBASE_BUCKET_PASSWORD=\r\n        restart: always<\/pre>\n<p>We&#8217;ve included another service called\u00a0<code>couchbase<\/code> with a bunch of port mappings and environment variables. There is something important to note here though. Remember the\u00a0<code>COUCHBASE_HOST<\/code> in the PHP section? It has a host which must match the service name of our database which is\u00a0<code>couchbase<\/code>.<\/p>\n<h2>Deploy the Containers with Docker<\/h2>\n<p>With the foundation in place, it is time to deploy the two containers so we have a functional set of microservices.<\/p>\n<p>From the Docker CLI, execute the following:<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">docker-compose run -d --service-ports --name couchbase couchbase\r\ndocker-compose run -d --service-ports --name php php<\/pre>\n<p>The above commands will build and deploy each of the images with the ports defined in the Compose file. From the web browser, https:\/\/localhost:8091 should get you to the Couchbase Server dashboard, and https:\/\/localhost:8080 should get you to your PHP application.<\/p>\n<p>With success, you should see information saved to the database and displayed on the screen.<\/p>\n<h2>Conclusion<\/h2>\n<p>You just saw how to containerize and deploy a PHP application that communicates with a Couchbase NoSQL container. While our choice of application was simple, it can easily be extended to something more complicated using any of the available PHP frameworks.<\/p>\n<p>This same guide can be seen with <a href=\"https:\/\/www.couchbase.com\/blog\/deploy-node-js-couchbase-web-application-docker-containers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Node.js<\/a>, <a href=\"https:\/\/www.couchbase.com\/blog\/deploy-golang-web-application-couchbase-docker-containers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Golang<\/a>, and <a href=\"https:\/\/www.couchbase.com\/blog\/docker-deploy-containerized-java-couchbase-web-application\/\" target=\"_blank\" rel=\"noopener noreferrer\">Java<\/a>. If you&#8217;d like to learn more about containerizing Couchbase Server, I wrote a more thorough version <a href=\"https:\/\/www.thepolyglotdeveloper.com\/2017\/04\/using-couchbase-docker-deploying-containerized-nosql-cluster\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p>For more information on the Couchbase PHP SDK, check out the <a href=\"https:\/\/www.couchbase.com\/developers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Couchbase Developer Portal<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier in the year I wrote about containerizing applications written in various development technologies that communicate with Couchbase Server. For example, I had written about deploying a Golang application with Docker, a Java application with Docker, and a Node.js application [&hellip;]<\/p>\n","protected":false},"author":63,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,1815,1816,9408],"tags":[1554,1519],"ppma_author":[9032],"class_list":["post-3744","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-best-practices-and-tutorials","category-couchbase-server","category-php","tag-container","tag-docker"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.0 (Yoast SEO v26.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deploy a PHP with Couchbase Application as Docker Containers<\/title>\n<meta name=\"description\" content=\"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploy a PHP with Couchbase Application as Docker Containers\" \/>\n<meta property=\"og:description\" content=\"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thepolyglotdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-13T14:15:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:28:57+00:00\" \/>\n<meta name=\"author\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nraboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Deploy a PHP with Couchbase Application as Docker Containers\",\"datePublished\":\"2017-06-13T14:15:01+00:00\",\"dateModified\":\"2025-06-14T04:28:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\"},\"wordCount\":956,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"container\",\"docker\"],\"articleSection\":[\"Application Design\",\"Best Practices and Tutorials\",\"Couchbase Server\",\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\",\"name\":\"Deploy a PHP with Couchbase Application as Docker Containers\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2017-06-13T14:15:01+00:00\",\"dateModified\":\"2025-06-14T04:28:57+00:00\",\"description\":\"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploy a PHP with Couchbase Application as Docker Containers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"caption\":\"Nic Raboy, Developer Advocate, Couchbase\"},\"description\":\"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.\",\"sameAs\":[\"https:\/\/www.thepolyglotdeveloper.com\",\"https:\/\/www.facebook.com\/thepolyglotdeveloper\",\"https:\/\/x.com\/nraboy\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/nic-raboy-2\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Deploy a PHP with Couchbase Application as Docker Containers","description":"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/","og_locale":"en_US","og_type":"article","og_title":"Deploy a PHP with Couchbase Application as Docker Containers","og_description":"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.","og_url":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2017-06-13T14:15:01+00:00","article_modified_time":"2025-06-14T04:28:57+00:00","author":"Nic Raboy, Developer Advocate, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@nraboy","twitter_misc":{"Written by":"Nic Raboy, Developer Advocate, Couchbase","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Deploy a PHP with Couchbase Application as Docker Containers","datePublished":"2017-06-13T14:15:01+00:00","dateModified":"2025-06-14T04:28:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/"},"wordCount":956,"commentCount":1,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["container","docker"],"articleSection":["Application Design","Best Practices and Tutorials","Couchbase Server","PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/","url":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/","name":"Deploy a PHP with Couchbase Application as Docker Containers","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2017-06-13T14:15:01+00:00","dateModified":"2025-06-14T04:28:57+00:00","description":"Learn how to deploy a PHP application as a Docker container that communicates with Couchbase Server, also in Docker container format.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/deploy-php-couchbase-application-docker-containers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Deploy a PHP with Couchbase Application as Docker Containers"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, Developer Advocate, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354","url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","caption":"Nic Raboy, Developer Advocate, Couchbase"},"description":"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.","sameAs":["https:\/\/www.thepolyglotdeveloper.com","https:\/\/www.facebook.com\/thepolyglotdeveloper","https:\/\/x.com\/nraboy"],"url":"https:\/\/www.couchbase.com\/blog\/author\/nic-raboy-2\/"}]}},"authors":[{"term_id":9032,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","author_category":"","last_name":"Raboy","first_name":"Nic","job_title":"","user_url":"https:\/\/www.thepolyglotdeveloper.com","description":"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=3744"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3744\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=3744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=3744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=3744"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}