Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach to container from docker compose restarts container

I have 2 services with 2 different images in my docker-compose.yml, when I run "docker-compose up -d", containers are started properly, but when i try to do "docker attach ", container restarts.

Can anyone please explain this behavior. How can attach to the container?

like image 718
Srinivasa Prasad Avatar asked Mar 19 '18 14:03

Srinivasa Prasad


People also ask

How do I stop my docker container from automatically restarting?

You can use the --restart=unless-stopped option, as @Shibashis mentioned, or update the restart policy (this requires docker 1.11 or newer); See the documentation for docker update and Docker restart policies. Use docker update --restart=no $(docker ps -a -q) to update all your containers :-) Great answer!!

Does docker compose restart containers?

However, Docker Compose allows us to configure restart policies to manage multiple containers by using the restart or restart_policy properties in normal mode or swarm mode.

Does restarting docker restart all containers?

no Do not automatically restart the container. (the default) on-failure Restart the container if it exits due to an error, which manifests as a non-zero exit code. always Always restart the container if it stops.

How do I restart a container from another container?

It is possible to grant a container access to docker so that it can spawn other containers on your host. You do this by exposing the docker socket inside the container, e.g: docker run -v /var/run/docker. sock:/var/run/docker.


1 Answers

if you want to go to your running compose container you can start new shell and attach to it

docker-compose exec servicename sh

or if you really want to attach to it just do docker-compose up

like image 127
Mazel Tov Avatar answered Oct 29 '22 21:10

Mazel Tov