- Learn OpenShift
- Denis Zuev Artemii Kropachev Aleksey Usov
- 181字
- 2021-08-13 16:03:46
Executing commands inside a container
From the output, we can see that the container status is UP. Now we can execute some commands inside the container using the docker exec command with different options:
$ docker exec -i 00f343906df3 ls -l /
total 12
drwxr-xr-x. 2 root root 4096 Feb 15 04:18 bin
drwxr-xr-x. 2 root root 6 Nov 19 15:32 boot
drwxr-xr-x. 5 root root 360 Mar 6 21:17 dev
drwxr-xr-x. 42 root root 4096 Mar 6 21:17 etc
drwxr-xr-x. 2 root root 6 Nov 19 15:32 home
...
Output truncated for brevity
...
Option -i (--interactive) allows you to run a Docker without dropping inside the container. But we can easily override this behavior and enter this container by using -i and -t (--tty) options (or just -it):
$ docker exec -it 00f343906df3 /bin/bash
root@00f343906df3:/usr/local/apache2#
We should fall into container bash CLI. From here, we can execute other general Linux commands. This trick is very useful for troubleshooting. To exit the container console, just type exit or press Ctrl + D.
推薦閱讀
- 30天自制操作系統(tǒng)
- 鴻蒙生態(tài):開啟萬(wàn)物互聯(lián)的智慧新時(shí)代
- Windows Server 2012 Hyper-V Cookbook
- Mastering KVM Virtualization
- Linux內(nèi)核觀測(cè)技術(shù)BPF
- Kali Linux 2018:Windows Penetration Testing
- Application Development in iOS 7
- Django Project Blueprints
- AWS SysOps Cookbook
- VMware Horizon View Essentials
- Python UNIX和Linux系統(tǒng)管理指南
- Linux網(wǎng)絡(luò)操作系統(tǒng)項(xiàng)目教程(RHEL 7.4/CentOS 7.4)(第3版)(微課版)
- Web Penetration Testing with Kali Linux(Third Edition)
- Zabbix監(jiān)控系統(tǒng)之深度解析和實(shí)踐
- 計(jì)算機(jī)系統(tǒng)平臺(tái)