devStandard/docs/learning/f-docker/docker常见问题.md
2025-03-29 14:35:49 +08:00

32 lines
803 B
Markdown
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# docker常见问题
## 进入容器失败
```bash
$ docker exec -it 345db9dd50a3 /bin/bash
# 报错
# OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: "/": permission denied: unknown
# 原因: docker中没有bash, 换成/bin/sh
# ps: 容器中没有ls, 只有ll
```
## 修改docker中的文件
使用`docker cp`
1).根据容器id使用docker cp把这个文件复制出来``docker cp 容器id:/data/spider.py /home/runnian/``
2).修改完成后把文件复制回容器中原来的位置:``docker cp /home/runnian/spider.py 容器id:/data/``
## 常见命令
查看容器:`docker ps -a`
查看运行的容器:`docker ps`
进入容器:`docker attach 容器ID`
`docker exec -it 容器ID /bin/bash `
退出容器: `exit`