i am searching since two days for a in my opinion very simple problem.
I want to execute a ls from one container on an other one.
They both run on a Docker for Windows .
I have a docker-compose.yml:
You can’t do that. The containers are isolated from each other; they have separate filesystems and process spaces, among other things. That’s one of the key goals of Docker.
$ docker stack deploy -c docker-compose.yml test
Creating network test_default
Creating service test_c1
Creating service test_c2
Now you can access /data/ from both containers.
$ docker exec -ti test_c2.1.8zfvzp9dkadgsxe4ugvrwnomv touch /data/test
$ docker exec -ti test_c1.1.bxal1ljjfd5918d1mcukuy5s4 ls /data/
test
I would advise against sshd in containers. running ssh just to execute processes?
You could potentially map the /var/run/docker.sock into the container so that they can use the DockerAPI to execute processes; but that is also risky, as this provides all the docker power to the container.