By using AWS re:Post, you agree to the Terms of Use
/Accessing Custom Environment Variables inside component's docker containers/

Accessing Custom Environment Variables inside component's docker containers

0

I have a manifest file which looks like :

{
      "Platform": {
        "os": "all"
      },
      "Lifecycle": {
        "Setenv": {
          "ENDPOINT": "Test_endpoint"
        },
        "Run": "docker rm core -f && docker rm A -f && docker rm B -f && docker rm C -f && docker-compose -f {artifacts:path}/docker-compose.yml up -d"
      },
      "Artifacts": [
        {
          "URI": "docker:D"
        },
        {
          "URI": "s3://bucket/docker-compose.yml"
        },
        {
          "URI": "docker:C"
        },
        {
          "URI": "docker:B"
        },
        {
          "URI": "docker:A"
        }
      ]
}

and in docker compose file

service:
    image: "XXXXX.dkr.ecr.us-east-1.amazonaws.com/service-1.0:latest"
    container_name: service
    network_mode: host
    environment:
      AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT: ${AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT}
      SVCUID: ${SVCUID}
      AWS_CONTAINER_CREDENTIALS_FULL_URI: ${AWS_CONTAINER_CREDENTIALS_FULL_URI}
      AWS_CONTAINER_AUTHORIZATION_TOKEN: ${AWS_CONTAINER_AUTHORIZATION_TOKEN}
      AWS_REGION: ${AWS_REGION}
      AWS_IOT_THING_NAME: ${AWS_IOT_THING_NAME}
      ENDPOINT: ${ENDPOINT}
    depends_on:
      - core
      - ledservice
      - scannerservice
    volumes:
      - ${AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT}:${AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT}
    command: --uri localhost:4400 --port 9100 --name stow

But i am unable to retrieve the value of ENDPOINT in my docker container using System.getEnv("ENDPOINT") or print all the environment variable using printenv on SSH. Value being returned is 'ENDPOINT=' i.e. empty.

What am i doing wrong here? because i could not find much references where Setenv is being used or how to use it using docker.

  • Could you run this command to see what environment variables are set inside the container? docker inspect --format='{{.Config.Env}}' aws-iot-greengrass

1 Answers
0

Hello Shivam, Was the suggestion from vaibhavmurkute useful? Please let us know.

MODERATOR
answered 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions