docker_practice/container/attach_exec.md

57 lines
1.8 KiB
Go
Raw Normal View History

#
使 `-d`
使 `docker attach` `docker exec` 使 `docker exec`
## `attach`
2019-01-06 09:40:31 +08:00
使 `docker attach`
```bash
$ docker run -dit ubuntu
243c32535da7d142fb0e6df616a3c3ada0b8ab417937c853a9e1c251f499f550
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
243c32535da7 ubuntu:latest "/bin/bash" 18 seconds ago Up 17 seconds nostalgic_hypatia
$ docker attach 243c
root@243c32535da7:/#
```
** stdin exit
2014-09-25 15:42:21 +08:00
## `exec`
### `-i` `-t`
`docker exec` `-i` `-t`
`-i` Linux
`-i` `-t` 使 Linux
```bash
$ docker run -dit ubuntu
69d137adef7a8a689cbcb059e94da5489d3cddd240ff675c640c8d96e84fe1f6
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69d137adef7a ubuntu:latest "/bin/bash" 18 seconds ago Up 17 seconds zealous_swirles
$ docker exec -i 69d1 bash
ls
bin
boot
dev
...
$ docker exec -it 69d1 bash
root@69d137adef7a:/#
2014-09-25 15:42:21 +08:00
```
stdin exit使 `docker exec`
使 `docker exec --help`