Scenario: local development with Docker

We will continue the previous scenario (Scenario: working with micro-services) by Dockerizing the two services. If you haven’t done the steps of the previous scenario, run this to get started:

cd /tmp
git clone

# Copy the end state of part 1 of the tutorial
cp -rf ./dodo-commands-tutorial/part1/after ./tutorial

# Create and activate a dodo environment for our project
cd ./tutorial
$(dodo env --init tutorial)

Running the docker-compose file

Our services come with Docker files that we have not used so far.

cat /tmp/tutorial/docker-compose.yml

    version: "3"
        image: dodo_tutorial
          dockerfile: ./Dockerfile
          context: .
          - ./writer:/app
          - ./time.log:/time.log
        working_dir: /app
        command: make runserver
        depends_on: [writer]
        image: dodo_tutorial
          - ./reader:/app
          - ./time.log:/time.log
        working_dir: /app
        command: make runserver

cat /tmp/tutorial/Dockerfile

    FROM python:3.7-alpine

    RUN apk add make

Using the docker-compose command

We’d like to be able to bring this docker system up from any directory with the dodo docker-compose up command. To facilitate this, we’ll create a new configuration layer in /tmp/tutorial/.dodo_commands/docker.yaml.

# Create a new file /tmp/tutorial/.dodo_commands/docker.yaml

  cwd: ${/ROOT/project_dir}


We could also have added the DOCKER_COMPOSE section directly to config.yaml. It’s up to you to decide when parts of the configuration should be moved to a separate layer file.

Detail sections

Open the adjacent tabs for more detail sections

Running a command inside a container

We’ll now take a look at how we can add a command script that runs inside a Docker container. We’ll first add a new command (mk-greet) without worrying about Docker. This new command script will run the greeting Makefile command.

# In: /tmp/tutorial/writer/Makefile

  echo "Hello ${GREETING}"

We have a new command script but it is not yet running inside the tutorial_writer_1 Docker container. Let’s fix this.

We first need to tell Dodo Commands that the mk-greet command is dockerized:

# /tmp/tutorial/.dodo_commands/server.writer.yaml
  # other stuff
    docker: [mk-greet]

We also need to specify in which container the mk-greet command should run:

# /tmp/tutorial/.dodo_commands/writer.yaml
    container: tutorial_writer_1


The keys in the DOCKER_OPTIONS take wild-cards, so instead of mk-greet we could have used *. In our example, this would mean that any dockerized script uses the tutorial_writer_1 container.

Detail sections

Open the adjacent tabs for more detail sections