{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/machine/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Running test scenarios using Docker-Compose","description":"Everything about Mosaic Journeys, SDKs, and APIs","siteUrl":"https://developer.transmitsecurity.com/","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"running-test-scenarios-using-docker-compose","__idx":0},"children":["Running test scenarios using Docker-Compose"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Integrating with our MIM IDP involves running a dedicated client application on your machine. This client interacts with the MIM IDP, facilitates management of the workload's identity, and exposes the workload to locally-running processes. This guide describes how to use ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.docker.com/compose/"},"children":["docker-compose"]}," to run a simple side-car pattern with the MIM client (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tsmim"]},")."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/machine/quick_start_jwt_auth"},"children":["Quickstart"]}," for how to implement workload authentication scenarios."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-create-a-docker-image","__idx":1},"children":["1. Create a Docker Image"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use the binary inside a docker container, we first need to create a container image. We can use the following Dockerfile:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# syntax = docker/dockerfile:1.4\nFROM alpine:latest\nWORKDIR =/opt/mim\nCOPY ./tsmim ./tsmim\nUSER nobody:nogroup\nCMD [\"version\"]\nENTRYPOINT [ \"./tsmim\", \"run\" ]\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Assuming this content is saved as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mim-client.Dockerfile"]}," in the same folder containing the Linux binary ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tsmim"]},", we can run the following command to build the image:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"$ docker build . -t mim-client -f mim-client.Dockerfile\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-configure-and-run-docker","__idx":2},"children":["2. Configure and run Docker"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now that we have the image, we can define the manifest for our docker-compose spec file - ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["docker-compose.yaml"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"version: \"3.8\"\n\nservices:\n  app:\n    image: alpine\n    command: 'sh -c \"while ! wget --header \\\"Authorization: Bearer ${API_KEY}\\\" -qO- http://tsmim:3014/peer/v1/id_token; do sleep 1; done\"'\n    depends_on:\n      - tsmim\n\n  tsmim:\n    image: mim-client:latest\n    environment:\n      - MIM_API_KEY=${API_KEY}\n    command: run --operator-base=example.mim.transmitsecurity.io --invite-code=${TICKET} --listen tsmim:3014 --dir /tmp\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-explained","__idx":3},"children":["Example explained"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Let’s breakdown the example:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We have a service called \"app\" which demonstrates utilization of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tsmim"]}," in order to obtain its identity, and a service called \"tsmim\" which acts as the side-car container running the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tsmim"]}," client."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We set the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--listen"]}," parameter of the Client binary to the same name as the docker-compose service (\"tsmim\"] , so that it automatically translates to the service’s internal network IP address (for example - ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["172.30.0.2"]},"). This allows the app service to reach the Client’s local API despite the fact the the services run on different containers."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Since the Client takes a few seconds to register with MIM IdP, in this example we implement a simple loop for the app service that keeps trying to reach the Client API until it receives a response."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For simplicity, we’ve assumed the API_KEY and TICKET values are set as environment variables (these can be set in a separate ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".env"]}," file). It’s important to note that these values are sensitive and should best be configured using an appropriate mechanism, such as ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.docker.com/compose/use-secrets/"},"children":["docker-compose secrets"]}," ."]}]}]}]},"headings":[{"value":"Running test scenarios using Docker-Compose","id":"running-test-scenarios-using-docker-compose","depth":1},{"value":"1. Create a Docker Image","id":"1-create-a-docker-image","depth":2},{"value":"2. Configure and run Docker","id":"2-configure-and-run-docker","depth":2},{"value":"Example explained","id":"example-explained","depth":2}],"frontmatter":{"title":"Testing using Docker-Compose","excludeFromSearch":true,"markdown":{"toc":{"depth":2}},"seo":{"title":"Running test scenarios using Docker-Compose"}},"lastModified":"2025-11-18T11:57:52.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/machine/test_with_docker","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}