When accessing a remote machine I'd like to know if a container was started over docker run
or docker-compose
or some other means.
Is that even possible?
EDIT: the main reason for this was to find out, where these containers are getting orchestrated, i.e. if the container goes down, will be started again? Where would that configuration be?
For investigation purposes I created the most simplest docker-compose.yml:
version: "2.4"
services:
hello:
image: "hello-world"
Then run it with docker-compose up
And lastly the normal way: docker run -it --name cli hello-world
So I had two stopped containers:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a8d53ff45a4 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago cli
d54f7a2ae8b2 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago compose_hello_1
Then I compared inspect output of both:
diff <(docker inspect cli) <(docker inspect compose_hello_1)
I found out that there are labels which compose creates:
"Labels": {}
---
"Labels": {
"com.docker.compose.config-hash": "251ebf43e00417fde81d3c53b9f3d8cd877e1beec00ebbffbc4a06c4db9c7b00",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "compose",
"com.docker.compose.service": "hello",
"com.docker.compose.version": "1.24.1"
}
Also compose uses another network:
"NetworkMode": "default",
---
"NetworkMode": "compose_default",
You should do it on your environment and try to find out differences where you can surely differentiate between both launch ways.