docker exec

Runs an extra command inside a container that is already running.

In more detail

The new process joins the container namespaces and filesystem but has its own lifetime and exit code; it is not the main process. docker exec -it name sh opens an interactive shell for diagnosis. It cannot enter a stopped container because there are no running namespaces to join.

Examples

docker exec -it command-demo sh
docker exec m01l02-broker rpk cluster info
echo login | docker exec -i broker rpk topic produce events

Related terms

Taught in

References

Certification courses