④.docker volume

解决容器数据的持久化

方式一
root@PC-20210619HHHN:~# ls /tmp
vscode-git-1df78c723a.sock                            vscode-ipc-5fd212ac-9ac0-408e-a7b4-77f7f0e5c1aa.sock
vscode-git-426f28e6b8.sock                            vscode-ipc-b840e484-2087-447b-943f-f8d71f0bf41c.sock
vscode-git-e0028e7b62.sock                            vscode-ipc-c7e17757-b6bb-4ce2-92ab-0df21ec4e85c.sock
vscode-ipc-423de9c9-732d-4e90-81da-e3402dc6466d.sock
root@PC-20210619HHHN:~# docker run -it --rm --name test -v /tmp:/tmp  centos:7  ls /tmp
vscode-git-1df78c723a.sock
vscode-git-426f28e6b8.sock
vscode-git-e0028e7b62.sock
vscode-ipc-423de9c9-732d-4e90-81da-e3402dc6466d.sock
vscode-ipc-5fd212ac-9ac0-408e-a7b4-77f7f0e5c1aa.sock
vscode-ipc-b840e484-2087-447b-943f-f8d71f0bf41c.sock
vscode-ipc-c7e17757-b6bb-4ce2-92ab-0df21ec4e85c.sock

持久mysql5.7 容器

 docker run --name mysql -p 3306:3306 -v /root/mysql/conf:/etc/mysql/conf.d  -v /root/mysql/data:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

方式二

docker volume ls

具名挂载
root@PC-20210619HHHN:~/mysql# docker volume ls
DRIVER    VOLUME NAME
local     html
root@PC-20210619HHHN:~/mysql# docker volume  inspect html
[
    {
        "CreatedAt": "2021-07-08T03:02:30Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/html/_data",
        "Name": "html",
        "Options": null,
        "Scope": "local"
    }
]
上一篇:tcp3-1


下一篇:IO 多路复用是什么意思?