{"id":17088,"date":"2017-05-11T12:15:00","date_gmt":"2017-05-11T09:15:00","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=17088"},"modified":"2017-05-11T11:14:25","modified_gmt":"2017-05-11T08:14:25","slug":"using-docker-compose-nodejs-development","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/","title":{"rendered":"Using Docker Compose for NodeJS Development"},"content":{"rendered":"<p>Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and reducing onboarding timelines considerably.<\/p>\n<p>To provide an example of how you might move to containerized development, I built a simple <code>todo<\/code> API using NodeJS, Express, and PostgreSQL using <a href=\"https:\/\/docs.docker.com\/compose\/\">Docker Compose<\/a> for development, testing, and eventually in my CI\/CD pipeline.<\/p>\n<p>In a two-part series, I will cover the development and pipeline creation steps. In this post, I will cover the first part: developing and testing with Docker Compose.<\/p>\n<h2>Requirements for This Tutorial<\/h2>\n<p>This tutorial requires you to have a few items before you can get started.<\/p>\n<ul>\n<li>Install <a href=\"https:\/\/store.docker.com\/search?type=edition&amp;offering=community\">Docker Community Edition<\/a><\/li>\n<li>Install <a href=\"https:\/\/docs.docker.com\/compose\/install\/\">Docker Compose<\/a><\/li>\n<li>Download <a href=\"https:\/\/github.com\/codeship-library\/nodejs-express-todoapp\/archive\/non-docker.zip\">Todo App Example \u2013 Non- Docker branch<\/a><\/li>\n<\/ul>\n<p>The todo app here is essentially a stand-in, and you could replace it with your own application. Some of the setup here is specific for this application, and the needs of your application may not be covered, but it should be a good starting point for you to get the concepts needed to Dockerize your own applications.<\/p>\n<p>Once you have everything set up, you can move on to the next section.<\/p>\n<h2>Creating the Dockerfile<\/h2>\n<p>At the foundation of any Dockerized application, you will find a <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\"><code>Dockerfile<\/code><\/a>. The <code>Dockerfile<\/code> contains all of the instructions used to build out the application image. You can set this up by installing NodeJS and all of its dependencies; however the Docker ecosystem has an image repository (the Docker Store) with a <a href=\"https:\/\/store.docker.com\/images\/node?tab=description\">NodeJS<\/a> image already created and ready to use.<\/p>\n<p>In the root directory of the application, create a new <code>Dockerfile<\/code>.<\/p>\n<pre class=\"brush:php\">\/&gt; touch Dockerfile<\/pre>\n<p>Open the newly created <code>Dockerfile<\/code> in your favorite editor. The first instruction, <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#from\"><code>FROM<\/code><\/a>, will tell Docker to use the prebuilt NodeJS image. There are several choices, but this project uses the <code>node:7.7.2-alpine<\/code> image. For more details about why I\u2019m using <code>alpine<\/code> here over the other options, you can read <a href=\"https:\/\/blog.codeship.com\/alpine-based-docker-images-make-difference-real-world-apps\/\">this post<\/a>.<\/p>\n<pre class=\"brush:php\">FROM node:7.7.2-alpine<\/pre>\n<p>If you run <code>docker build .<\/code>, you will see something similar to the following:<\/p>\n<pre class=\"brush:sql\">Sending build context to Docker daemon 249.3 kB\r\nStep 1\/1 : FROM node:7.7.2-alpine\r\n7.7.2-alpine: Pulling from library\/node\r\n709515475419: Pull complete\r\n1a7746e437f7: Pull complete\r\n662ac7b95f9d: Pull complete\r\nDigest: sha256:6dcd183eaf2852dd8c1079642c04cc2d1f777e4b34f2a534cc0ad328a98d7f73\r\nStatus: Downloaded newer image for node:7.7.2-alpine\r\n ---&gt; 95b4a6de40c3\r\nSuccessfully built 95b4a6de40c3<\/pre>\n<p>With only one instruction in the Dockerfile, this doesn\u2019t do too much, but it does show you the build process without too much happening. At this point, you now have an image created, and running <code>docker images<\/code> will show you the images you have available:<\/p>\n<pre class=\"brush:php\">REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\nnode                7.7.2-alpine        95b4a6de40c3        6 weeks ago         59.2 MB<\/pre>\n<p>The <code>Dockerfile<\/code> needs more instructions to build out the application. Currently it\u2019s only creating an image with NodeJS installed, but we still need our application code to run inside the container. Let\u2019s add some more instructions to do this and build this image again.<\/p>\n<p>This particular Docker file uses <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#run\"><code>RUN<\/code><\/a>, <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#copy\"><code>COPY<\/code><\/a>, and <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#workdir\"><code>WORKDIR<\/code><\/a>. You can read more about those on Docker\u2019s reference page to get a deeper understanding.<\/p>\n<p>Let\u2019s add the instructions to the <code>Dockerfile<\/code> now:<\/p>\n<pre class=\"brush:sql\">FROM node:7.7.2-alpine\r\n\r\nRUN apk update\r\nCOPY package.json \/tmp\/package.json\r\nRUN cd \/tmp &amp;&amp; npm install --quiet\r\nRUN mkdir -p \/usr\/app &amp;&amp; cp -a \/tmp\/node_modules \/usr\/app\r\n\r\nWORKDIR \/usr\/app\r\nCOPY .\/ \/usr\/app\/<\/pre>\n<p>Here is what is happening:<\/p>\n<ul>\n<li>Update <code>apk<\/code> packages<\/li>\n<li>Copy the <code>package.json<\/code> file to <code>tmp<\/code><\/li>\n<li>Install <code>node_modules<\/code> in <code>tmp<\/code><\/li>\n<li>Copy the <code>node_modules<\/code> to <code>\/usr\/app<\/code><\/li>\n<li>Set the working directory to <code>\/usr\/app<\/code><\/li>\n<li>Copy all the files from the project\u2019s root to <code>\/usr\/app<\/code><\/li>\n<\/ul>\n<p>We initially install into <code>tmp<\/code> to make use of the cache layers I talked about earlier. By doing it this way, we are able to cache <code>node_modules<\/code> and not install them every time we build the image unless there are new ones to be installed.<\/p>\n<p>You can now run <code>docker build .<\/code> again and see the results:<\/p>\n<pre class=\"brush:sql\">Sending build context to Docker daemon 249.3 kB\r\nStep 1\/7 : FROM node:7.7.2-alpine\r\n ---&gt; 95b4a6de40c3\r\nStep 2\/7 : RUN apk update\r\n ---&gt; Running in 9e1ba27dcd8d\r\nfetch http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/main\/x86_64\/APKINDEX.tar.gz\r\nfetch http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/community\/x86_64\/APKINDEX.tar.gz\r\nv3.4.6-101-g85afbbc [http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/main]\r\nv3.4.6-83-g67e50bc [http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/community]\r\nOK: 5972 distinct packages available\r\n ---&gt; fe85afcf457d\r\nRemoving intermediate container 9e1ba27dcd8d\r\nStep 3\/7 : COPY package.json \/tmp\/package.json\r\n ---&gt; 5bcbc25f16f1\r\nRemoving intermediate container 7bdfe092ce5e\r\nStep 4\/7 : RUN cd \/tmp &amp;&amp; npm install --quiet\r\n ---&gt; Running in 57f5ac4618ec\r\n\r\n ### NPM MODULES INSTALLED ###\r\n\r\n ---&gt; 525f662aeacf\r\nRemoving intermediate container 57f5ac4618ec\r\nStep 5\/7 : RUN mkdir -p \/usr\/app &amp;&amp; cp -a \/tmp\/node_modules \/usr\/app\r\n ---&gt; Running in 05529fe28f41\r\n ---&gt; 58dc99530a26\r\nRemoving intermediate container 05529fe28f41\r\nStep 6\/7 : WORKDIR \/usr\/app\r\n ---&gt; 394a19b73f96\r\nRemoving intermediate container be09c6bcae84\r\nStep 7\/7 : COPY .\/ \/usr\/app\/\r\n ---&gt; 7b591e02ded3\r\nRemoving intermediate container 7bfb004ad51f\r\nSuccessfully built 7b591e02ded3<\/pre>\n<p>You have now successfully created the application image using Docker. Currently, however, our app won\u2019t do much since we still need a database, and we want to connect everything together. This is where Docker Compose will help us out.<\/p>\n<h2>Docker Compose Services<\/h2>\n<p>Now that you know how to create an image with a <code>Dockerfile<\/code>, let\u2019s create an application as a service and connect it to a database. Then we can run some setup commands and be on our way to creating that new todo list.<\/p>\n<p>Create the file <code>docker-compose.yml<\/code>:<\/p>\n<pre class=\"brush:php\">\/&gt; touch docker-compose.yml<\/pre>\n<p>The <a href=\"https:\/\/docs.docker.com\/compose\/compose-file\/compose-file-v2\/\">Docker Compose file<\/a> will define and run the containers based on a configuration file. We are using <a href=\"https:\/\/docs.docker.com\/compose\/compose-file\/compose-file-v2\/\">compose file version 2<\/a> syntax, and you can read up on it on Docker\u2019s site.<\/p>\n<p>An important concept to understand is that Docker Compose spans \u201cbuildtime\u201d and \u201cruntime.\u201d Up until now, we have been building images using <code>docker build .<\/code>, which is \u201cbuildtime.\u201d This is when our containers are actually built. We can think of \u201cruntime\u201d as what happens once our containers are built and being used.<\/p>\n<p>Compose triggers \u201cbuildtime\u201d \u2014 instructing our images and containers to build \u2014 but it also populates data used at \u201cruntime,\u201d such as env vars and volumes. This is important to be clear on. For instance, when we add things like <code>volumes<\/code> and <code>command<\/code>, they will override the same things that may have been set up via the Dockerfile at \u201cbuildtime.\u201d<\/p>\n<p>Open your <code>docker-compose.yml<\/code> file in your editor and copy\/paste the following lines:<\/p>\n<pre class=\"brush:php\">version: '2'\r\nservices:\r\n  web:\r\n    build: .\r\n    command: npm run dev\r\n    volumes:\r\n      - .:\/usr\/app\/\r\n      - \/usr\/app\/node_modules\r\n    ports:\r\n      - \"3000:3000\"\r\n    links:\r\n      - postgres\r\n    environment:\r\n      DATABASE_URL: postgres:\/\/todoapp@postgres\/todos\r\n  postgres:\r\n    image: postgres:9.6.2-alpine\r\n    environment:\r\n      POSTGRES_USER: todoapp\r\n      POSTGRES_DB: todos<\/pre>\n<p>This will take a bit to unpack, but let\u2019s break it down by service.<\/p>\n<h3>The web service<\/h3>\n<p>The first directive in the web service is to <code>build<\/code> the image based on our <code>Dockerfile<\/code>. This will recreate the image we used before, but it will now be named according to the project we are in, <code>nodejsexpresstodoapp<\/code>. After that, we are giving the service some specific instructions on how it should operate:<\/p>\n<ul>\n<li><code>command: npm run dev<\/code> \u2013 Once the image is built, and the container is running, the <code>npm run dev<\/code> command will start the application.<\/li>\n<li><code>volumes:<\/code> \u2013 This section will mount paths between the host and the container.<\/li>\n<li><code>.:\/usr\/app\/<\/code> \u2013 This will mount the root directory to our working directory in the container.<\/li>\n<li><code>\/usr\/app\/node_modules<\/code> \u2013 This will mount the <code>node_modules<\/code> directory to the host machine using the buildtime directory.<\/li>\n<li><code>links:<\/code> \u2013 This will create a dependency and create the environment variable to network the services together.<\/li>\n<li><code>environment:<\/code> \u2013 The application itself expects the environment variable <code>DATABASE_URL<\/code> to run. This is set in <code>db.js<\/code>.<\/li>\n<li><code>ports:<\/code> \u2013 This will publish the container\u2019s port, in this case <code>3000<\/code>, to the host as port <code>3000<\/code>.<\/li>\n<\/ul>\n<p>The <code>DATABASE_URL<\/code> is the connection string. <code>postgres:\/\/todoapp@postgres\/todos<\/code> connects using the <code>todoapp<\/code> user, on the host <code>postgres<\/code>, using the database <code>todos<\/code>.<\/p>\n<blockquote><p>This Compose file uses \u201clinks.\u201d The preference here is <a href=\"https:\/\/docs.docker.com\/compose\/compose-file\/compose-file-v2\/#dependson\"><code>depends_on<\/code><\/a>, however, Codeship currently doesn\u2019t support <code>depends_on<\/code>. This will make the transition from local to CI\/CD easier at a later step.<\/p><\/blockquote>\n<h3>The Postgres service<\/h3>\n<p>Like the NodeJS image we used, the Docker Store has a prebuilt image for <a href=\"https:\/\/store.docker.com\/images\/022689bf-dfd8-408f-9e1c-19acac32e57b?tab=description\">PostgreSQL<\/a>. Instead of using a <code>build<\/code> directive, we can use the name of the image, and Docker will grab that image for us and use it. In this case, we are using <code>postgres:9.6.2-alpine<\/code>. We could leave it like that, but it has <code>environment<\/code> variables to let us customize it a bit.<\/p>\n<p><code>environment:<\/code> \u2013 This particular image accepts a couple environment variables so we can customize things to our needs. <code>POSTGRES_USER: todoapp<\/code> \u2013 This creates the user <code>todoapp<\/code> as the default user for PostgreSQL. <code>POSTGRES_DB: todos<\/code> \u2013 This will create the default database as <code>todos<\/code>.<\/p>\n<h2>Running The Application<\/h2>\n<p>Now that we have our services defined, we can build the application using <code>docker-compose up<\/code>. This will show the images being built and eventually starting. After the initial build, you will see the names of the containers being created:<\/p>\n<pre class=\"brush:php\">Pulling postgres (postgres:9.6.2-alpine)...\r\n9.6.2-alpine: Pulling from library\/postgres\r\n627beaf3eaaf: Pull complete\r\ne351d01eba53: Pull complete\r\ncbc11f1629f1: Pull complete\r\n2931b310bc1e: Pull complete\r\n2996796a1321: Pull complete\r\nebdf8bbd1a35: Pull complete\r\n47255f8e1bca: Pull complete\r\n4945582dcf7d: Pull complete\r\n92139846ff88: Pull complete\r\nDigest: sha256:7f3a59bc91a4c80c9a3ff0430ec012f7ce82f906ab0a2d7176fcbbf24ea9f893\r\nStatus: Downloaded newer image for postgres:9.6.2-alpine\r\nBuilding web\r\n...\r\nCreating nodejsexpresstodoapp_postgres_1\r\nCreating nodejsexpresstodoapp_web_1\r\n...\r\nweb_1       | Your app is running on port 3000<\/pre>\n<p>At this point, the application is running, and you will see log output in the console. You can also run the services as a background process, using <code>docker-compose up -d<\/code>. During development, I prefer to run without <code>-d<\/code> and create a second terminal window to run other commands. If you want to run it as a background process and view the logs, you can run <code>docker-compose logs<\/code>.<\/p>\n<p>At a new command prompt, you can run <code>docker-compose ps<\/code> to view your running containers. You should see something like the following:<\/p>\n<pre class=\"brush:php\">Name                            Command              State           Ports\r\n------------------------------------------------------------------------------------------------\r\nnodejsexpresstodoapp_postgres_1   docker-entrypoint.sh postgres   Up      5432\/tcp\r\nnodejsexpresstodoapp_web_1        npm run dev                     Up      0.0.0.0:3000-&gt;3000\/tcp<\/pre>\n<p>This will tell you the name of the services, the command used to start it, its current state, and the ports. Notice <code>nodejsexpresstodoapp_web_1<\/code> has listed the port as <code>0.0.0.0:3000-&gt;3000\/tcp<\/code>. This tells us that you can access the application using <code>localhost:3000\/todos<\/code> on the host machine.<\/p>\n<pre class=\"brush:php\">\/&gt; curl localhost:3000\/todos\r\n\r\n[]<\/pre>\n<p>The <code>package.json<\/code> file has a script to automatically build the code and migrate the schema to PostgreSQL. The schema and all of the data in the container will persist as long as the <code>postgres:9.6.2-alpine<\/code> image is not removed.<\/p>\n<p>Eventually, however, it would be good to check how your app will build with a clean setup. You can run <code>docker-compose down<\/code>, which will clear things that are built and let you see what is happening with a fresh start.<\/p>\n<p>Feel free to check out the source code, play around a bit, and see how things go for you.<\/p>\n<h2>Testing the Application<\/h2>\n<p>The application itself includes some integration tests built using <a href=\"https:\/\/facebook.github.io\/jest\/\"><code>jest<\/code><\/a>. There are various ways to go about testing, including creating something like <code>Dockerfile.test<\/code> and <code>docker-compose.test.yml<\/code> files specific for the test environment. That\u2019s a bit beyond the current scope of this article, but I want to show you how to run the tests using the current setup.<\/p>\n<p>The current containers are running using the project name <code>nodejsexpresstodoapp<\/code>. This is a default from the directory name. If we attempt to run commands, it will use the same project, and containers will restart. This is what we don\u2019t want.<\/p>\n<p>Instead, we will use a different project name to run the application, isolating the tests into their own environment. Since containers are ephemeral (short-lived), running your tests in a separate set of containers makes certain that your app is behaving exactly as it should in a clean environment.<\/p>\n<p>In your terminal, run the following command:<\/p>\n<pre class=\"brush:php\">\/&gt; docker-compose -p tests run -p 3000 --rm web npm run watch-tests<\/pre>\n<p>You should see <code>jest<\/code> run through integration tests and wait for changes.<\/p>\n<p>The <code>docker-compose<\/code> command accepts several <a href=\"https:\/\/docs.docker.com\/compose\/reference\/overview\/\">options<\/a>, followed by a command. In this case, you are using <code>-p tests<\/code> to run the services under the <code>tests<\/code> project name. The command being used is <a href=\"https:\/\/docs.docker.com\/compose\/reference\/run\/\"><code>run<\/code><\/a>, which will execute a one-time command against a service.<\/p>\n<p>Since the <code>docker-compose.yml<\/code> file specifies a port, we use <code>-p 3000<\/code> to create a random port to prevent port collision. The <code>--rm<\/code> option will remove the containers when we stop the containers. Finally, we are running in the <code>web<\/code> service <code>npm run watch-tests<\/code>.<\/p>\n<h2>Conclusion<\/h2>\n<p>At this point, you should have a solid start using Docker Compose for local app development. In the next part of this series about using Docker Compose for NodeJS development, I will cover integration and deployments of this application using Codeship.<\/p>\n<p>Is your team using Docker in its development workflow? If so, I would love to hear about what you are doing and what benefits you see as a result.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/blog.codeship.com\/using-docker-compose-for-nodejs-development\/\">Using Docker Compose for NodeJS Development<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Kelly Andrews at the <a href=\"http:\/\/blog.codeship.com\/\">Codeship Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and reducing onboarding timelines considerably. To provide an example of how you might move to containerized development, I built a simple todo API using NodeJS, Express, and PostgreSQL using Docker Compose &hellip;<\/p>\n","protected":false},"author":508,"featured_media":10356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[217],"class_list":["post-17088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js","tag-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Docker Compose for NodeJS Development - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and\" \/>\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.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Docker Compose for NodeJS Development - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-11T09:15:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kelly Andrews\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kelly Andrews\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\"},\"author\":{\"name\":\"Kelly Andrews\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5\"},\"headline\":\"Using Docker Compose for NodeJS Development\",\"datePublished\":\"2017-05-11T09:15:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\"},\"wordCount\":1658,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"keywords\":[\"Docker\"],\"articleSection\":[\"Node.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\",\"name\":\"Using Docker Compose for NodeJS Development - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2017-05-11T09:15:00+00:00\",\"description\":\"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Node.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Using Docker Compose for NodeJS Development\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5\",\"name\":\"Kelly Andrews\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d3cf8726eb4aa4a8eef1bd2a91e5dee3f8b061bfeb9aea16b96f8f140c20d1b3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d3cf8726eb4aa4a8eef1bd2a91e5dee3f8b061bfeb9aea16b96f8f140c20d1b3?s=96&d=mm&r=g\",\"caption\":\"Kelly Andrews\"},\"description\":\"Kelly J Andrews is the Developer Advocate at Codeship. When he\u2019s not busy defending JavaScript, you can find him somewhere singing karaoke. If you see him in the wild, ask him to do a magic trick.\",\"sameAs\":[\"https:\/\/blog.codeship.com\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/kelly-andrews\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Docker Compose for NodeJS Development - Web Code Geeks - 2026","description":"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and","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.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/","og_locale":"en_US","og_type":"article","og_title":"Using Docker Compose for NodeJS Development - Web Code Geeks - 2026","og_description":"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-05-11T09:15:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","type":"image\/jpeg"}],"author":"Kelly Andrews","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Kelly Andrews","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/"},"author":{"name":"Kelly Andrews","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5"},"headline":"Using Docker Compose for NodeJS Development","datePublished":"2017-05-11T09:15:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/"},"wordCount":1658,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","keywords":["Docker"],"articleSection":["Node.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/","name":"Using Docker Compose for NodeJS Development - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2017-05-11T09:15:00+00:00","description":"Docker is an amazing tool for developers. It allows us to build and replicate images on any host, removing the inconsistencies of dev environments and","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/using-docker-compose-nodejs-development\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Node.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/"},{"@type":"ListItem","position":4,"name":"Using Docker Compose for NodeJS Development"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5","name":"Kelly Andrews","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d3cf8726eb4aa4a8eef1bd2a91e5dee3f8b061bfeb9aea16b96f8f140c20d1b3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d3cf8726eb4aa4a8eef1bd2a91e5dee3f8b061bfeb9aea16b96f8f140c20d1b3?s=96&d=mm&r=g","caption":"Kelly Andrews"},"description":"Kelly J Andrews is the Developer Advocate at Codeship. When he\u2019s not busy defending JavaScript, you can find him somewhere singing karaoke. If you see him in the wild, ask him to do a magic trick.","sameAs":["https:\/\/blog.codeship.com"],"url":"https:\/\/www.webcodegeeks.com\/author\/kelly-andrews\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/508"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17088"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17088\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/10356"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=17088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}