Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
Docker attach
This command to attach your terminal’s standard input, output, and error (or any combination of the three) to a running container using the container’s ID or name. attach the running container with the following command. you need to press enter once execute the below command, docker is waiting for your input.
docker attach nodeapi
once attached, you can do all the cli commands like you can check the node version, run the bundle file, exit etc..
But the problem here once you exit out of this, your container is no logger in the up status. your container is also in exit status.
Docker exec
The docker exec command runs a new command in a running container. execute the below command after restarting container nodeapi in the above command.
// start the container
docker start nodeapi
// execute the exec command
docker exec -it nodeapi bash
you can exit now and if you list the containers now we can see container is still running.