{"id":2009,"date":"2026-07-22T00:24:44","date_gmt":"2026-07-21T17:24:44","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/22\/how-to-use-docker-for-development-a-practical-guide\/"},"modified":"2026-07-22T00:24:44","modified_gmt":"2026-07-21T17:24:44","slug":"how-to-use-docker-for-development-a-practical-guide","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/22\/how-to-use-docker-for-development-a-practical-guide\/","title":{"rendered":"How to Use Docker for Development: A Practical Guide"},"content":{"rendered":"<h1>How to Use Docker for Development: A Practical Guide<\/h1>\n<p>Docker simplifies development by packaging your app and its dependencies into isolated containers. This ensures consistency across your local machine, teammate&#8217;s setup, and production servers. Instead of manually installing databases, runtimes, or system tools, you define everything in a <code>Dockerfile<\/code> and <code>docker-compose.yml<\/code>. Here\u2019s how to get started.<\/p>\n<h2>1. Set Up Your Docker Environment<\/h2>\n<p>Install Docker Desktop for your OS. Verify with <code>docker --version<\/code>. Then create a project folder and add a <code>Dockerfile<\/code> that describes your app\u2019s base image, dependencies, and start command. For a Node.js app, it might look like:<\/p>\n<ul>\n<li><code>FROM node:18-alpine<\/code><\/li>\n<li><code>WORKDIR \/app<\/code><\/li>\n<li><code>COPY package*.json .\/<\/code><\/li>\n<li><code>RUN npm install<\/code><\/li>\n<li><code>COPY . .<\/code><\/li>\n<li><code>CMD [\"npm\", \"start\"]<\/code><\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/via.placeholder.com\/800x600\/4a90d9\/ffffff?text=how%20to%20use%20Docker%20for%20development\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>2. Use Docker Compose for Multi\u2011Service Apps<\/h2>\n<p>Most development projects need more than one service (e.g., app + database). Create a <code>docker-compose.yml<\/code> file in the root directory. Define each service under <code>services:<\/code>. Example for a Node app with MongoDB:<\/p>\n<ul>\n<li><code>services:<\/code><\/li>\n<li><code>  app:<\/code> \u2013 builds from your <code>Dockerfile<\/code>, maps port 3000, mounts code as a volume for live reload.<\/li>\n<li><code>  db:<\/code> \u2013 uses <code>mongo:6<\/code>, maps port 27017, sets environment variables.<\/li>\n<\/ul>\n<p>Run <code>docker-compose up<\/code> to start everything. Changes to your source code reflect instantly thanks to volumes.<\/p>\n<h2>3. Leverage Volumes and Hot Reloading<\/h2>\n<p>Volumes synchronize your local code into the container so you can edit files without rebuilding. Add a volume under your service definition: <code>volumes: - .:\/app<\/code>. This maps the current directory to <code>\/app<\/code> in the container. Pair it with a dev server (like <code>nodemon<\/code>) so containers restart automatically on file changes.<\/p>\n<h2>4. Manage Dependencies and Environment<\/h2>\n<p>Use Docker\u2019s <code>.env<\/code> file for secrets and configuration. Define variables in <code>docker-compose.yml<\/code> under <code>env_file<\/code>. For database URLs, API keys, or port overrides, this keeps your code portable. Never commit <code>.env<\/code> to version control \u2013 add it to <code>.gitignore<\/code>.<\/p>\n<p><strong>Conclusion<\/strong>: Docker removes \u201cit works on my machine\u201d frustrations. Start with a simple <code>Dockerfile<\/code>, extend with Compose for multiple services, and use volumes for live development. Once you master these basics, you can easily add testing, CI\/CD pipelines, and production deployments. Try it on your next project \u2013 the learning curve pays off quickly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Use Docker for Development: A Practical Guide Docker simplifies development by packaging your app and its dependencies into isolated containers. This ensures consistency across your local machine, teammate&#8217;s setup, and production servers. Instead of manually installing databases, runtimes, or system tools, you define everything in a Dockerfile and docker-compose.yml. Here\u2019s how to get &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-2009","post","type-post","status-publish","format-standard","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/users\/2716"}],"replies":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/comments?post=2009"}],"version-history":[{"count":0,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2009\/revisions"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=2009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=2009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=2009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}