Example used to try a compose application with Docker Dev Environments

compose-dev-env

Example used to try a Compose application with Docker Dev Environments.

This example is based on the nginx-golang-mysql sample of awesome-compose repository.

Compose sample application

Go server with an Nginx proxy and a MariaDB database

Project structure:

.
├── backend
│   ├── Dockerfile
│   ├── go.mod
│   └── main.go
├── db
│   └── password.txt
├── docker-compose.yaml
├── proxy
│   ├── conf
│   └── Dockerfile
└── README.md

docker-compose.yaml

services:
  backend:
    build: backend
    ...
  db:
    image: mariadb
    ...
  proxy:
    build: proxy
    ports:
    - 80:80
    ...

The compose file defines an application with three services proxy, backend and db. When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file. Make sure port 80 on the host is not already being in use.

Deploy with docker-compose

$ docker-compose up -d
Creating network "compose-dev-env_default" with the default driver
Creating volume "compose-dev-env_db-data" with default driver
Building backend
Step 1/8 : FROM golang:1.13-alpine AS build
1.13-alpine: Pulling from library/golang
...
Successfully built 5f7c899f9b49
Creating compose-dev-env_db_1 ... done
Creating compose-dev-env_backend_1 ... done
Creating compose-dev-env_proxy_1   ... done

Expected result

Listing containers must show three containers running and the port mapping as below:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
d6752b317e6d   compose-dev-env_proxy                 "nginx -g 'daemon of…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, :::80->80/tcp   compose-dev-env_proxy_1
70bf9182ea52   compose-dev-env_backend               "/server"                About a minute ago   Up About a minute   8000/tcp                            compose-dev-env_backend_1
c67de604799d   mariadb                               "docker-entrypoint.s…"   About a minute ago   Up About a minute   3306/tcp                            compose-dev-env_db_1

After the application starts, navigate to http://localhost:80 in your web browser or run:

$ curl localhost:80
["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"]

Stop and remove the containers

$ docker-compose down
Owner
Docker Samples
Official Docker Samples
Docker Samples
Comments
  • README.md proxy port mismatch

    README.md proxy port mismatch

    The README.md has a port mismatch between the text here:

    https://github.com/dockersamples/compose-dev-env/blob/f0ff602db59dc9f4d64b3cbf84641b9575780ba2/README.md?plain=1#L41-L42

    And the ports defined here:

    https://github.com/dockersamples/compose-dev-env/blob/f0ff602db59dc9f4d64b3cbf84641b9575780ba2/docker-compose.yaml#L20-L25

    and here:

    https://github.com/dockersamples/compose-dev-env/blob/f0ff602db59dc9f4d64b3cbf84641b9575780ba2/.docker/docker-compose.yaml#L28-L33

    The change in https://github.com/dockersamples/compose-dev-env/pull/6 updated the port mapping in README.md and in .docker/docker-compose-yaml but didn't update the ports in the root-leveldocker-compose.yaml file.

    This causes the instructions in "Deploy with docker-compose" to be wrong, as following:

    https://github.com/dockersamples/compose-dev-env/blob/f0ff602db59dc9f4d64b3cbf84641b9575780ba2/README.md?plain=1#L44-L47

    Will use the root level docker-compose.yaml, causing the proxy to be exposed on port 80, not 8080, as suggested in the section "Expected result":

    https://github.com/dockersamples/compose-dev-env/blob/f0ff602db59dc9f4d64b3cbf84641b9575780ba2/README.md?plain=1#L71

    The fix is presumably a one line change in the proxy ports of docker-compose.yaml to match those in .docker/docker-compose.yaml?

  • CGO has to be disabled for alpine image

    CGO has to be disabled for alpine image

    Faced this issue while running your go binary with in alpine container. Export the following variable before building your bin

    docker run backend
    sh: can't open '/run.sh': No such file or directory
    
  • Fix port in README.md

    Fix port in README.md

    @glours When creating a dev env from this repo the compose file used is .docker/docker-compose.yaml and not the one at the root of the directory. Therefore we need to update the README.md accordingly to update the proxy port to 8080 instead of 80.

    curl localhost:8080
    ["Blog post #0","Blog post #1","Blog post #2","Blog post #3","Blog post #4"]
    
  • CGO has to be disabled for alpine image

    CGO has to be disabled for alpine image

    Faced this issue while running your go binary with in alpine container. Export the following variable before building your bin

    docker run backend
    sh: can't open '/run.sh': No such file or directory
    
  • A thank you note

    A thank you note

    Hi! Thanks so much for your work on these resources. As a teacher, I appreciate your commitment to teaching and learning. I know it takes plenty of time and energy to design quality learning material.

    I am learning Docker, and it's going well! I noticed a few things that piqued my curiosity, so I asked a few questions inside commit discussions. Cheers 🍺!

  • Exit status 17: backend: no such file or directory

    Exit status 17: backend: no such file or directory

    While trying to load this commit as a Dev Environment with Docker Desktop 4.2.0 (70708) on Mac OS 11.6, I get this non-intermittent failure:

    Detecting main repo language...
    Detected 'Go' as the main repository language.
    could not find /var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-charming_wright/proxy/var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-charming_wright/proxy: stat /var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-charming_wright/proxy/var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-charming_wright/proxy: no such file or directory
    exit status 17
    

    This is reproducible even with clicking the link under "Try running a sample" on the dashboard: image

    Although, this time it complained about a different folder missing:

    Detected 'Go' as the main repository language.
    could not find /var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-pensive_wozniak/backend/var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-pensive_wozniak/backend: stat /var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-pensive_wozniak/backend/var/folders/1f/wfpcf_k14gx_kx8sxsw3473m0000gn/T/volume-compose-dev-env-pensive_wozniak/backend: no such file or directory
    exit status 17
    
Mutagen Compose is a modified version of Docker Compose that offers automated integration with Mutagen.

Mutagen Compose Mutagen Compose is a (minimally) modified version of Docker Compose that offers automated integration with Mutagen. This allows you to

Dec 22, 2022
Easily run your Compose application to the cloud with compose-cli

This CLI tool makes it easy to run Docker containers and Docker Compose applications in the cloud using either Amazon Elastic Container Service (ECS) or Microsoft Azure Container Instances (ACI) using the Docker commands you already know.

Jan 8, 2023
I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify each line.

go-samples I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify

Mar 16, 2022
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.

GIT-PIPE Hassle-free minimal CI/CD for git repos for docker-based projects. Features: zero configuration for repos by default automatic encrypted back

Sep 23, 2022
Tool to convert docker-compose files to set of simple docker commands

docker-decompose Tool to convert docker-compose files to set of simple docker commands. Install Use go get to install the latest version of the librar

Apr 12, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Dec 30, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Feb 16, 2022
Composer is a simple process manager for dev environments.

Composer Composer is a simple service manager for dev environments. How to build/install it? To build composer under ./bin, run: make build To build

May 12, 2022
Sample multi docker compose environment setup

Instructions This is a demonstration of a Multi Docker Compose. The purpose of this repositoy is ongoing research on "Docker compose" architecture des

Oct 21, 2022
Mesos Framework to use docker-compose files.
Mesos Framework to use docker-compose files.

mesos-compose Mesos Framework to use docker-compose files. Requirements Apache Mesos min 1.6.0 Mesos with SSL and Authentication is optional Redis Dat

Dec 14, 2022
Execute multiple shell commands like Docker-Compose

parx parx is a simple tool to run multiple commands in parallel while having the output structured like Docker Compose does that. This is useful when

Aug 15, 2022
Docker-compose files for running full Storj network locally

docker-compose based Storj environment storj-up is a swiss-army tool to create / customize Storj clusters with the help of docker-compose (not just st

Nov 16, 2022
Katenary - Convert docker-compose to a configurable helm chart
Katenary - Convert docker-compose to a configurable helm chart

Katenary is a tool to help transforming docker-compose files to a working Helm C

Dec 23, 2022
Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments.
Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments.

Reward Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments. It makes possible to run multiple local envir

Dec 9, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

Dec 13, 2022
The example shows how to build a simple multi-tier web application using Kubernetes and Docker
The example shows how to build a simple multi-tier web application using Kubernetes and Docker

Guestbook Example This example shows how to build a simple multi-tier web application using Kubernetes and Docker. The application consists of a web f

Nov 15, 2021
GitHub Action: Compose multiple (conditional) checks into a single check based on file paths in a pull request
GitHub Action: Compose multiple (conditional) checks into a single check based on file paths in a pull request

GitHub Action: Composite Example Usage --- name: All Checks on: pull_request: branches: - main jobs: meta: runs-on: - ubuntu-20.

Dec 29, 2022
Bubbleboxer - compose bubbles into boxes

bubbleboxer ?? - compose bubbles into boxes ?? A way to compose multiple bubbles

Dec 20, 2022
Template Compose - Continues Delivery

Template Compose - Continues Delivery

Feb 4, 2022