Restart docker container from another container I'm in a planning phase for a little tool for myself. I have to say that I have close to 0 experience with docker.

My setup


1 x Nodejs App in a Container (lets call it App)
n x Instances/Containers of the same image (lets call it Agent)


What I want  

I'm looking for a way to restart one of the Agents from within my App.

The problem
I just managed to create my first docker-compose. From here I'm stuck. I just have no idea how to cross-access the container from my Apps container (by script) or if this is even possible and then force to restart it (like docker restart #hash does).

My current docker-compose.yml (if that helps in any way)  

version: '3'
services:
    app:
        container_name: app
        volumes: 
            - .:/usr/src/app
        restart: always
        build: .
        ports:
            - '8080:3000'
        links:
            - agent

    # no control over this as this is an existing image from docker hub
    agent:
        restart: always
        image: image/from/dockerhub
        ports:
            - '1234'


... which I would run as docker-compose up --scale agent=n.  

I'm not necessarily looking for a complete solution. If someone could guide me into the right direction I would really appreciate it.

Thanks
In majority of circumstances I wouldn't recommend this in production, but to restart docker container from another container, you need to install docker in that container and then run that "master" container with

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


as described here: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ (look for "The solution" part of the article).

But check your architecture and see if you really need to restart one container from another or if there is some other way.