We use a docker-compose.yaml file to launch a process management container. In development this is a DevContainer, in production it is a process that monitors running docker containers. We let this container interact with the hosts Docker instance by passing in:

      - /var/run/docker.sock:/var/run/docker.sock

When containers are started from inside this container, we have noticed they inherit the service name of the initial container, as specified in docker-compose.yaml. We first noticed this when our log aggregation service (Mezmo / LogDNA) reported the app name incorrectly as the initial service name, instead of the expected container name.

How do we fix this?

1

There are 1 best solutions below

0
On

It turns out you can override the service name of your container when launching it from the command line with this parameter:

    --label com.docker.compose.service={app}

for example something like this:

    docker run --name myApp --label com.docker.compose.service=myApp myApp-image:latest