Docker exec: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "==exec== <pre> docker exec -it <image-name> bash </pre>")
 
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
==exec==
=External=


<pre>
* https://docs.docker.com/engine/reference/commandline/exec/
docker exec -it <image-name> bash  
 
</pre>
=Internal=
 
* [[Docker_Client_Operations#Container_Lifecycle_Operations|Container Lifecycle Operations]]
 
=Overview=
 
Attaches to a running container. This command can run new process in already running container (container must a have PID 1 process running already).
 
docker exec [-u <''uid''>] -it <''running-container-name-or-ID''> bash
 
=Options=
 
==-i==
 
Interactive.
 
==-t==
 
Allocated pseudo-TTY
 
=Scenarios=
 
==Attach to a Running Container==
 
As the current user:
 
docker exec -it <''container-id''> /bin/bash
 
As root:
 
docker exec -u 0 -it <''container-id''> /bin/bash

Latest revision as of 23:39, 24 January 2018

External

Internal

Overview

Attaches to a running container. This command can run new process in already running container (container must a have PID 1 process running already).

docker exec [-u <uid>] -it <running-container-name-or-ID> bash

Options

-i

Interactive.

-t

Allocated pseudo-TTY

Scenarios

Attach to a Running Container

As the current user:

docker exec -it <container-id> /bin/bash

As root:

docker exec -u 0 -it <container-id> /bin/bash