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 \"". I also tried using xdotool, but it can’t identify the docker shell terminal tabs for some reason.

  • Dockerfile: How to replace a placeholder in environment variable with build-arg's?
  • docker-compose not found from script
  • Development environment in Docker
  • Automatically configure Java to use the maximum RAM allocated to its Docker container
  • Creating bash script from Dockerfile strips comments
  • How to substitute variable value in “docker run” command
  • 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?

  • Docker-Composer exited with code 0
  • mounting docker-machine VM folders in container with docker-compose
  • ASP.NET Core Docker port forwarding on Ubuntu 16.10
  • Run Jenkins master and slave with Docker
  • set hostname service docker swarm
  • Dockerize ASP Classic on IIS
  • 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'
        image: postgres
        build: .
        command: bundle exec rails s -p 3000 -b ''
          - .:/myapp
          - "3000:3000"
          - db
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.