Deploying docker-compose.yml -- what to do about ${DOCKER_LOGIN} field?

In my docker.compose.yml, I have lines like this:

image: ${DOCKER_LOGIN}/myapp:${TAG}

This is how the “image” field is defined by default in the Torizon single-container template.
My problem is: when I deploy the docker-compose.yml to the target, it will have these environment variables which are not set. In fact, when I run the build task, DOCKER_LOGIN bizarrely is given the value 192.168.11.119:5002 (my own PC’s IP address).

What do I do when I deploy this docker-compose.yml file to /var/sota/storage/docker-compose? Do I hard-code my own PC’s IP address in the yml file to replace the environment variable? That seems very wrong to me.

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Great question—this situation is common when moving from development to production with Torizon.

The ${DOCKER_LOGIN} environment variable being set to your local IP (e.g., 192.168.11.119:5002) is indeed expected during development, as this refers to your development-time local container registry. However, this is not suitable for production deployment.

For production deployment, you should not hard-code your PC’s IP address. Instead, you should use the dedicated task for production images, which manages this substitution properly.

Steps for Production Deployment

  1. Use the create-production-image Task:
    This special task will:

    • Build your container image
    • Push it to a public or private container registry (like DockerHub)
    • Automatically generate a docker-compose.prod.yml file
      In this file, environment variables like ${DOCKER_LOGIN} and ${TAG} are replaced with the actual values (e.g., your DockerHub login and correct image tag), making it safe to deploy on your target device.
  2. Deploy the docker-compose.prod.yml Instead:

    • After running the task, use the generated docker-compose.prod.yml for the deployment to /var/sota/storage/docker-compose instead of your original docker-compose.yml.
    • Do not manually edit or hard-code values into your .yml files.
  3. If you need changes:

    • Update your original docker-compose.yml
    • Re-run the create-production-image task
    • Deploy the newly generated docker-compose.prod.yml

Summary:
No, you should not hard-code your PC’s IP in the docker-compose.yml. Always prepare your application for production using the create-production-image task—the system will substitute variables with the right values.

For more details, see the documentation:

Best regards,
Toradex AI Assistant.

Which docker-compose should I use as the docker-compose in my torizoncore-builder bundle step? Should I create the docker-compose-production.yml then copy-paste it into my torizoncore project? Can I refer to it directly from my torizoncore builder project?

The image: field should point to the Docker registry your container image is stored. The extension has tasks that will automatically do this for you as documented here: Build, Test and Push Applications for Production | Toradex Developer Center

This includes creating a final production ready docker-compose file.

You can ignore the section about Torizon Cloud if you are not using this, as this would not apply to you.

Best Regards,
Jeremias