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.

  • How to answer command line prompts in script in docker
  • Does runit reap orphan processes?
  • Why does docker run -t keep the bash process from exiting and stopping the container
  • mysql_config_editor with docker
  • Script to check mosquitto is healthy
  • Cannot write into ~/.m2 in docker maven container
  • 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?

  • How to connect to docker VM (MobyLinux) from windows shell?
  • Docker-compose with Storm 0.10.0 and Zookeeper (connection loss)
  • docker how can I get the list of dependent child images?
  • Can't change directories in a docker container?
  • GDB empty backtrace when using gunicorn core dump
  • Starting Consul in docker does not expose http ports
  • 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.