{"id":19535,"date":"2017-12-18T12:15:16","date_gmt":"2017-12-18T10:15:16","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=19535"},"modified":"2017-12-14T11:38:50","modified_gmt":"2017-12-14T09:38:50","slug":"using-docker-compose-python-development","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/","title":{"rendered":"Using Docker Compose for Python 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 with <a href=\"https:\/\/www.python.org\/\">Python<\/a>, <a href=\"www.django-rest-framework.org\">Django REST Framework<\/a>, 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\/python-django-todoapp\/archive\/non-docker.zip\">Todo app example \u2014 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. 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 Python and all of its dependencies. However, the Docker ecosystem has an image repository with a <a href=\"https:\/\/store.docker.com\/images\/python\">Python<\/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 Python image. There are several choices, but this project uses the <code>python:3.6.1-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:py\">FROM python:3.6.1-alpine<\/pre>\n<p>If you run <code>docker build .<\/code>, you will see something similar to the following:<\/p>\n<pre class=\"brush:py\">Sending build context to Docker daemon  10.53MB\r\nStep 1\/1 : FROM python:3.6.1-alpine\r\n3.6.1-alpine: Pulling from library\/python\r\n90f4dba627d6: Pull complete\r\n19bc0bb0be9f: Pull complete\r\ne05eff433916: Pull complete\r\ne70196200a87: Pull complete\r\na6d780959950: Pull complete\r\nDigest: sha256:0945574465b917d524ce9b748479a286c2ed3c5a97311ac5950464907d4d8b53\r\nStatus: Downloaded newer image for python:3.6.1-alpine\r\n ---&gt; ddd6300d05a3\r\nSuccessfully built ddd6300d05a3<\/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\npython              3.6.1-alpine        ddd6300d05a3        5 weeks ago         88.7MB<\/pre>\n<p>The <code>Dockerfile<\/code> needs more instructions to build out the application. Currently it\u2019s only creating an image with Python 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\">RUN<\/a>, <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#copy\">COPY<\/a>, and <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#workdir\">WORKDIR<\/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:py\">FROM python:3.6.1-alpine\r\n\r\nRUN apk update \\\r\n  &amp;&amp; apk add \\\r\n    build-base \\\r\n    postgresql \\\r\n    postgresql-dev \\\r\n    libpq\r\n\r\nRUN mkdir \/usr\/src\/app\r\nWORKDIR \/usr\/src\/app\r\nCOPY .\/requirements.txt .\r\nRUN pip install -r requirements.txt\r\n\r\nENV PYTHONUNBUFFERED 1\r\n\r\nCOPY . .<\/pre>\n<p>Here is what is happening:<\/p>\n<ul>\n<li>Update <code>apk<\/code> packages and then install a few additional requirements<\/li>\n<li>Make the directory <code>\/usr\/src\/app<\/code><\/li>\n<li>Set the working directory <code>\/usr\/src\/app<\/code><\/li>\n<li>Copy <code>requirements.txt<\/code> to the working directory<\/li>\n<li>Run pip install with the <code>requirements.txt<\/code> file<\/li>\n<li>Set the environment variable <code>PYTHONUNBUFFERED<\/code> to 1<\/li>\n<li>Copy all the files from the project\u2019s root to the working directory<\/li>\n<\/ul>\n<p>You can now run <code>docker build .<\/code> again and see the results:<\/p>\n<pre class=\"brush:py\">Sending build context to Docker daemon  10.53MB\r\nStep 1\/8 : FROM python:3.6.1-alpine\r\n ---&gt; ddd6300d05a3\r\nStep 2\/8 : RUN apk update   &amp;&amp; apk add     build-base     postgresql     postgresql-dev     libpq\r\n ---&gt; Running in 22bfdcf8a0dd\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-165-g6b9a79f [http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/main]\r\nv3.4.6-160-g14ad2a3 [http:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.4\/community]\r\nOK: 5974 distinct packages available\r\n\r\n## APK packages installed ##\r\n\r\nExecuting busybox-1.24.2-r13.trigger\r\nOK: 215 MiB in 65 packages\r\n ---&gt; 782357cafece\r\nRemoving intermediate container 22bfdcf8a0dd\r\nStep 3\/8 : ENV PYTHONUNBUFFERED 1\r\n ---&gt; Running in 0d6de64f5f8b\r\n ---&gt; 609106526013\r\nRemoving intermediate container 0d6de64f5f8b\r\nStep 4\/8 : RUN mkdir \/usr\/src\/app\r\n ---&gt; Running in b30ac1098156\r\n ---&gt; 17def88f6c5f\r\nRemoving intermediate container b30ac1098156\r\nStep 5\/8 : WORKDIR \/usr\/src\/app\r\n ---&gt; 158d43ac2a47\r\nRemoving intermediate container fef446ea4ed0\r\nStep 6\/8 : COPY .\/requirements.txt .\r\n ---&gt; 2751d1f4c313\r\nRemoving intermediate container a49b090cb8e3\r\nStep 7\/8 : RUN pip install -r requirements.txt\r\n ---&gt; Running in eaf9912e4810\r\n\r\n## PIP Requirements Installed ##\r\n\r\nInstalling collected packages: pytz, Django, djangorestframework, psycopg2, django-cors-headers, dj-database-url, gunicorn, virtualenv\r\nSuccessfully installed Django-1.11.3 dj-database-url-0.4.2 django-cors-headers-2.1.0 djangorestframework-3.6.3 gunicorn-19.7.1 psycopg2-2.7.2 pytz-2017.2 virtualenv-15.1.0\r\n ---&gt; dfcca42a45b0\r\nRemoving intermediate container eaf9912e4810\r\nStep 8\/8 : COPY . .\r\n ---&gt; 61f356fba3ea\r\nRemoving intermediate container fda87c3db8cf\r\nSuccessfully built 61f356fba3ea<\/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 Docker Compose file 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 version 3<\/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 works at \u201cruntime.\u201d Up until now, we have been building images using <code>docker build .<\/code> \u2014 this is \u201cbuildtime.\u201d This is especially important when we add things like <code>volumes<\/code> and <code>command<\/code> because they will override what is set up at \u201cbuildtime.\u201d<\/p>\n<p>For example, the <code>usr\/src\/app<\/code> directory will be created during the build. We then map that directory to the host machine, and the host machine application code will be used during \u201cruntime.\u201d This allows us to make changes locally, and those are then accessible in the container.<\/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: '3'\r\nservices:\r\n  web:\r\n    build: .\r\n    command: gunicorn -b 0.0.0.0:8000 todosapp.wsgi:application\r\n    depends_on:\r\n      - postgres\r\n    volumes:\r\n      - .:\/usr\/src\/app\r\n    ports:\r\n      - \"8000:8000\"\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>name<\/code>. After that, we are giving the service some specific instructions on how it should operate:<\/p>\n<ul>\n<li><code>command: gunicorn -b 0.0.0.0:8000 todosapp.wsgi:application<\/code> \u2013 Once the image is built, and the container is running, this command will start the application.<\/li>\n<li><code>depends_on:<\/code> \u2013 This will tell Docker Compose to start up the <code>postgres<\/code> service when the <code>web<\/code> service runs.<\/li>\n<li><code>volumes:<\/code> \u2013 This section will mount paths between the host and the container.<\/li>\n<li><code>.:\/usr\/src\/app<\/code> \u2013 This will mount the root directory to our working directory in the container.<\/li>\n<li><code>environment:<\/code> \u2013 The application itself expects the environment variable <code>DATABASE_URL<\/code> to run.<\/li>\n<li><code>ports:<\/code> \u2013 This will publish the container\u2019s port, in this case <code>8000<\/code>, to the host as port <code>8000<\/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<h3>The Postgres service<\/h3>\n<p>Like the Python image we used, the Docker Store has a prebuilt image for <a href=\"https:\/\/store.docker.com\/images\/postgres\">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<ul>\n<li><code>environment:<\/code> \u2013 This particular image accepts a couple environment variables so we can customize things to our needs.<\/li>\n<li><code>POSTGRES_USER: todoapp<\/code> \u2013 This creates the user <code>todoapp<\/code> as the default user for PostgreSQL.<\/li>\n<li><code>POSTGRES_DB: todos<\/code> \u2013 This will create the default database as <code>todos<\/code>.<\/li>\n<\/ul>\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\ncfc728c1c558: Pull complete\r\nb749e72b24f9: Pull complete\r\n0abdb8c9c36b: Pull complete\r\n90ca3848ef7e: Pull complete\r\n3ecf037a5034: Pull complete\r\n9327e3c5554c: Pull complete\r\n3133782bad17: Pull complete\r\n143bac6c8910: Pull complete\r\nd6da9f4bd18e: Pull complete\r\nDigest: sha256:f88000211e3c682e7419ac6e6cbd3a7a4980b483ac416a3b5d5ee81d4f831cc9\r\nStatus: Downloaded newer image for postgres:9.6.2-alpine\r\nBuilding web\r\n...\r\nCreating pythondjangotodoapp_postgres_1 ...\r\nCreating pythondjangotodoapp_postgres_1 ... done\r\nCreating pythondjangotodoapp_web_1 ...\r\nCreating pythondjangotodoapp_web_1 ... done\r\n...\r\nweb_1       | [2017-08-03 13:23:18 +0000]  () [INFO] Starting gunicorn 19.7.1\r\nweb_1       | [2017-08-03 13:23:18 +0000]  () [INFO] Listening at: http:\/\/0.0.0.0:8000 (1)<\/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\npythondjangotodoapp_postgres_1   docker-entrypoint.sh postgres    Up      5432\/tcp\r\npythondjangotodoapp_web_1        gunicorn -b 0.0.0.0:8000 t ...   Up      0.0.0.0:8000-&gt;8000\/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>pythondjangotodoapp_web_1<\/code> has listed the port as <code>0.0.0.0:8000-&gt;8000\/tcp<\/code>. This tells us that you can access the application using <code>localhost:8000\/todos<\/code> on the host machine.<\/p>\n<h3>Migrate the database schema<\/h3>\n<p>A small but important step not to overlook is the schema migration for the database. Compose comes with an <a href=\"https:\/\/docs.docker.com\/compose\/reference\/exec\/\"><code>exec<\/code><\/a> command that will execute a one-off command on a running container. The typical function to migrate schemas is <code>python manage.py migrate<\/code>. We can run that on the web service using <code>docker-compose exec<\/code>.<\/p>\n<pre class=\"brush:php\">\/&gt; docker-compose exec web python manage.py migrate\r\nOperations to perform:\r\n  Apply all migrations: admin, auth, contenttypes, sessions, todos\r\nRunning migrations:\r\n  Applying contenttypes.0001_initial... OK\r\n  Applying auth.0001_initial... OK\r\n  Applying admin.0001_initial... OK\r\n  Applying admin.0002_logentry_remove_auto_add... OK\r\n  Applying contenttypes.0002_remove_content_type_name... OK\r\n  Applying auth.0002_alter_permission_name_max_length... OK\r\n  Applying auth.0003_alter_user_email_max_length... OK\r\n  Applying auth.0004_alter_user_username_opts... OK\r\n  Applying auth.0005_alter_user_last_login_null... OK\r\n  Applying auth.0006_require_contenttypes_0002... OK\r\n  Applying auth.0007_alter_validators_add_error_messages... OK\r\n  Applying auth.0008_alter_user_username_max_length... OK\r\n  Applying sessions.0001_initial... OK\r\n  Applying todos.0001_initial... OK<\/pre>\n<p>Now we can try out the API:<\/p>\n<pre class=\"brush:php\">\/&gt; curl localhost:8000\/todos\r\n\r\n[]<\/pre>\n<p>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. 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. There are various ways to go about testing with Docker, including creating <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>pythondjangotodoapp<\/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 8000 --rm web python manage.py test\r\nStarting tests_postgres_1 ... done\r\nCreating test database for alias 'default'...\r\nSystem check identified no issues (0 silenced).\r\n........\r\n----------------------------------------------------------------------\r\nRan 8 tests in 0.086s\r\n\r\nOK\r\nDestroying test database for alias 'default'...<\/pre>\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 8000<\/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>python manage.py test<\/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 Python 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>Published on Web Code Geeks with permission by Kelly Andrews, partner at our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/blog.codeship.com\/using-docker-compose-for-python-development\/\" target=\"_blank\" rel=\"noopener\">Using Docker Compose for Python Development<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/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 with Python, Django REST Framework, and PostgreSQL using &hellip;<\/p>\n","protected":false},"author":508,"featured_media":10356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[217,290],"class_list":["post-19535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-docker","tag-python"],"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 Python 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\/devops\/using-docker-compose-python-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 Python 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\/devops\/using-docker-compose-python-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-12-18T10:15:16+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=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/\"},\"author\":{\"name\":\"Kelly Andrews\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5\"},\"headline\":\"Using Docker Compose for Python Development\",\"datePublished\":\"2017-12-18T10:15:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/\"},\"wordCount\":1616,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"keywords\":[\"Docker\",\"python\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/\",\"name\":\"Using Docker Compose for Python Development - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2017-12-18T10:15:16+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\/devops\/using-docker-compose-python-development\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-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\/devops\/using-docker-compose-python-development\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using Docker Compose for Python 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 Python 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\/devops\/using-docker-compose-python-development\/","og_locale":"en_US","og_type":"article","og_title":"Using Docker Compose for Python 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\/devops\/using-docker-compose-python-development\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-12-18T10:15:16+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":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/"},"author":{"name":"Kelly Andrews","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/9c8b9f76af498ec4deaafc4b9aa88fa5"},"headline":"Using Docker Compose for Python Development","datePublished":"2017-12-18T10:15:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/"},"wordCount":1616,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","keywords":["Docker","python"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/","url":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/","name":"Using Docker Compose for Python Development - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2017-12-18T10:15:16+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\/devops\/using-docker-compose-python-development\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-development\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/devops\/using-docker-compose-python-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\/devops\/using-docker-compose-python-development\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/www.webcodegeeks.com\/category\/devops\/"},{"@type":"ListItem","position":3,"name":"Using Docker Compose for Python 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\/19535","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=19535"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/19535\/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=19535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=19535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=19535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}