Difference between revisions of "Docker exec"
Jump to navigation
Jump to search
↑ https://docs.docker.com/engine/reference/commandline/exec/
↑ https://docs.docker.com/engine/reference/commandline/exec/
(30 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | * '''Login | + | {{lowercase}} |
+ | https://docs.docker.com/engine/reference/commandline/exec/ | ||
+ | |||
+ | docker exec -it my_container sh -c "echo a && echo b" | ||
+ | |||
+ | * '''Login'''/[[Connect into a running container]]: | ||
** <code>[[docker exec]]<ref>https://docs.docker.com/engine/reference/commandline/exec/</ref> -it <my_container_name> bash</code> | ** <code>[[docker exec]]<ref>https://docs.docker.com/engine/reference/commandline/exec/</ref> -it <my_container_name> bash</code> | ||
+ | ** <code>[[docker exec]]<ref>https://docs.docker.com/engine/reference/commandline/exec/</ref> -it <my_container_name> ps</code> | ||
** <code>docker exec -it <my_container_name> sh</code> | ** <code>docker exec -it <my_container_name> sh</code> | ||
+ | ** <code>[[docker run]] -it --user USER_NAME CONTAINER_NAME</code> | ||
− | Related | + | docker exec -it CONTAINER_NAME sh |
+ | unable to find user nginx: no matching entries in passwd file | ||
+ | |||
+ | docker exec -it festive_lewin sh | ||
+ | Error response from daemon: Container 2391a43638f822b1dc3e8d8c79c461959de2238c48d580c7092d5a278e5bd792 [[is not running]] | ||
+ | |||
+ | docker exec -u 0 -it CONTAINER_NAME bash | ||
+ | |||
+ | === Show [[Environment variables]] === | ||
+ | docker exec [[CONTAINER_NAME]] [[env]] | ||
+ | docker exec [[CONTAINER_NAME]] [[printenv]] | ||
+ | |||
+ | == Activities == | ||
+ | * [[Connect into a running container]] | ||
+ | |||
+ | == Related == | ||
* <code>[[kubectl exec]]</code> | * <code>[[kubectl exec]]</code> | ||
+ | * <code>[[podman exec]]</code> | ||
+ | * <code>[[crictl exec]]</code> | ||
* <code>[[docker system events]] --since '240m' | grep bash</code> | * <code>[[docker system events]] --since '240m' | grep bash</code> | ||
+ | * <code>[[podman attach]]</code> | ||
+ | * <code>[[docker attach]]</code> | ||
+ | * <code>[[docker-compose exec]]</code> | ||
+ | * [[Dsh]] [[Bash]] alias function for <code>docker exec -it CONTAINER_NAME [[bash|sh]]</code> | ||
+ | * <code>[[is restarting, wait until the container is running]]</code> | ||
+ | * [[aws ecs execute-command]] | ||
+ | * CTRL-p CTRL-q detach key sequence produces no effect, but pressing CTRL-c or typing exit terminates the container. | ||
+ | == See also == | ||
+ | * {{docker exec}} | ||
+ | * {{docker cmd}} | ||
− | |||
− | |||
[[Category:Docker]] | [[Category:Docker]] |
Latest revision as of 09:55, 21 March 2024
https://docs.docker.com/engine/reference/commandline/exec/
docker exec -it my_container sh -c "echo a && echo b"
- Login/Connect into a running container:
docker exec[1] -it <my_container_name> bash
docker exec[2] -it <my_container_name> ps
docker exec -it <my_container_name> sh
docker run -it --user USER_NAME CONTAINER_NAME
docker exec -it CONTAINER_NAME sh unable to find user nginx: no matching entries in passwd file
docker exec -it festive_lewin sh Error response from daemon: Container 2391a43638f822b1dc3e8d8c79c461959de2238c48d580c7092d5a278e5bd792 is not running
docker exec -u 0 -it CONTAINER_NAME bash
Show Environment variables[edit]
docker exec CONTAINER_NAME env docker exec CONTAINER_NAME printenv
Activities[edit]
Related[edit]
kubectl exec
podman exec
crictl exec
docker system events --since '240m' | grep bash
podman attach
docker attach
docker-compose exec
- Dsh Bash alias function for
docker exec -it CONTAINER_NAME sh
is restarting, wait until the container is running
- aws ecs execute-command
- CTRL-p CTRL-q detach key sequence produces no effect, but pressing CTRL-c or typing exit terminates the container.
See also[edit]
docker exec
docker
[config | pull
|push
|run
|start
, |stop
|cp
|events
|info
|version
|build
|commit
|image
|images
|image ls
|image inspect
|rmi
|rm
|tag
|exec | rename | manifest | save | service update | load
],docker --help
Advertising: