Docker Community Forums

Share and learn in the Docker community.

Exec vs Attach Commands


(Dan Jones) #1

I conceptually understand the difference between docker exec and docker attach. But what are the practical differences for when to use exec and when to use attach? It seems I can make each behave like the other.


(Ranjandas) #2

Hi,

Docker attach attaches to the process that runs in the container with PID 1. Where as Docker exec is used run a new process inside the container. Docker exec also gives you the feature to run the process as a different user and various other features.

Regards