天天看點

Docker常見錯誤一、存儲驅動錯誤二、啟動權限不夠三、服務啟動逾時四、登入界面重疊

一、存儲驅動錯誤

問題:

[[email protected] docker]# docker run hello-world
docker: Error response from daemon: error creating aufs mount to /var/lib/docker/aufs/mnt/9f1cc4ec95241a1432a23f4ee7a1eb1c3fcf239ad203f915668967685ded08c4-init: invalid argument.
See 'docker run --help'.
           

解決:

# 修改存儲類型
vim /etc/docker/daemon.json
{
  "storage-driver": "vfs",
  "registry-mirrors": ["https://v8o5rqy6.mirror.aliyuncs.com"]
}
# 重新開機docker服務
systemctl daemon-reload && systemctl restart docker
# 檢視docker資訊
[[email protected] docker]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.06.1-ce
# aufs修改成vfs
Storage Driver: vfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.15.0-111-generic
Operating System: CentOS Linux 7 (Core) (containerized)
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 1GiB
Name: xiaoqiang
ID: RWVR:PMVN:RXON:OQ5H:RNFU:MNWE:JVVZ:D76W:MIYT:YL2L:DPEI:LC7V
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support
# 運作成功
[[email protected] docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
# 存儲類型有
|Storage driver |Must match backing filesystem |
|---------------|------------------------------|
|overlay        |No                            |
|aufs           |No                            |
|btrfs          |Yes                           |
|devicemapper   |No                            |
|vfs            |No                            |
|zfs            |Yes                           |
           

二、啟動權限不夠

問題:

operation not permitted
           
[[email protected] nacos]# ls
data  docker-compose.yaml
[[email protected] nacos]# docker-compose up
Starting nacos ... error

ERROR: for nacos  Cannot start service nacos: OCI runtime create failed: container_linux.go:348: starting container process caused "operation not permitted": unknown

ERROR: for nacos  Cannot start service nacos: OCI runtime create failed: container_linux.go:348: starting container process caused "operation not permitted": unknown
ERROR: Encountered errors while bringing up the project.

           

解決:

去掉privileged或者加上privileged
           

三、服務啟動逾時

問題:

[email protected]:/home/qiang/docker-compose/nacos[[email protected] nacos]# docker-compose up -d && docker logs -f nacos
Creating network "nacos_default" with the default driver
Creating nacos ... 

ERROR: for nacos  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ERROR: for nacos  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).
           

解決:

vim /etc/profile
export COMPOSE_HTTP_TIMEOUT=500
export DOCKER_CLIENT_TIMEOUT=500
source /etc/profile
           

四、登入界面重疊

問題:

引起這個問題的原因是在使用"docker run"運作容器時使用了 “/sbin/init"和”–privileged"參數。使用/sbin/init啟動容器并加上–privileged參數,相當于docker容器獲得了主控端的全權委托權限。這時docker容器内部的init與主控端的init産生了混淆。

解決:

systemctl status [email protected].service
systemctl stop [email protected].service
systemctl disable [email protected].service
           

作者(Author):小強崽

來源(Source):https://www.wuduoqiang.com/archives/Docker常見錯誤

協定(License):署名-非商業性使用-相同方式共享 4.0 國際 (CC BY-NC-SA 4.0)

版權(Copyright):商業轉載請聯系作者獲得授權,非商業轉載請注明出處。 For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.