how to automate docker development environment startup for a multi-service web app (on Linux)

I currently have to do the following 9+ steps just to launch my dev stack using Docker on Ubuntu 16.04 before I can start writing code:

  • open a terminal and cd into service #1’s source code directory
  • docker-compose up service #1 (Python/Django, Redis, and Postgres containers)
  • docker exec service1 bash; start Django dev server for debugging
  • repeat for service #2, using terminal tabs to keep things organized
  • open a terminal and cd into the front-end Angular app source directory
  • run a webpack dev server with npm
  • open one or more terminals and cd into the appropriate source code directories to edit

I tried writing a shell script to launch everything with gnome-terminal --tab -e "bash -c docker-compose up", etc, but this gets awkward and will fail when trying to then shell into containers and run things, e.g. gnome-terminal --tab -e "bash -c \"docker-compose exec service1 bash -c rundev.sh \"". I also tried using xdotool, but it can’t identify the docker shell terminal tabs for some reason.

  • Docker - dynamic regex-based sed substitution in files
  • How to run an application inside docker safely
  • Docker: Alias command name to run another sibling docker container
  • set max time a docker container can be open
  • Bash script behaves differently from Docker run command instead of inside container itself?
  • docker - cannot find aws credentials in container although they exist
  • Running a SPA with two back-end services and doing local development on each of the three code-bases doesn’t seem like a bizarre use-case for Docker app development to me.

    Does anyone have any suggestions of tools or an alternative dev environment setup for simplifying things?

  • Jhipster CI (Jenkins 2 + Sonarqube) -> Memory Heap
  • Can't download python packages onto Docker image
  • Django wont start with Docker
  • Kubernetes & docker containers PCI DSS compliance
  • AWS Server setup with JIRA, Docker
  • Maven docker cache dependencies
  • One Solution collect form web for “how to automate docker development environment startup for a multi-service web app (on Linux)”

    You can do it with a bash script, but the proper way would be docker-compose. You need to create 2x services with their respective commands to run. Here is an example for rails app. Your docker-compose.yml should be something similar to this.

    version: '2'
    services:
      db:
        image: postgres
      web:
        build: .
        command: bundle exec rails s -p 3000 -b '0.0.0.0'
        volumes:
          - .:/myapp
        ports:
          - "3000:3000"
        depends_on:
          - db
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.