What is the difference between docker exec and attach?

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Docker Exec:

The docker container exec command runs a new command in a running container. The command started using docker exec only runs while the container’s primary process (PID 1) is running, and it is not restarted if the container is restarted.

docker exec [OPTIONS] CONTAINER COMMAND [ARG…]

Docker attach:

When we start a docker container, we need to decide if we want to run in a default foreground mode or the detached mode.

It will attach local standard input, output, and error streams to a running container.

docker attach [OPTIONS] CONTAINER

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x