docker容器内怎么连接外部的mysql
展开全部
1.用-v挂载主机数据卷到容器内[plain]viewplaincopydockerrun-v/path/to/hostdir:/mnt$container在容器内拷贝cp/mnt/sourcefile/path/to/destfile2.直接在主机上拷贝到容器物理存储系统A.获取容器名称或者id:[plain]viewplaincopy$dockerpsB.获取整个容器的id[plain]viewplaincopy$dockerinspect-f'{{.Id}}'步骤A获取的名称或者idC.在主机上拷贝文件:[plain]viewplaincopy$sudocppath-file-host/var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE或者$sudocppath-file-host/var/lib/docker/devicemapper/mnt/123abc>/rootfs/root例子:[plain]viewplaincopy$dockerpsCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESd8e703d7e303solidleon/ssh:latest/usr/sbin/sshd-Dcranky_pare$dockerinspect-f'{{.Id}}'cranky_pareor$dockerinspect-f'{{.Id}}'d8e703d7e303d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5$sudocpfile.txt/var/lib/docker/aufs/mnt/**d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e53.用输入输出符[plain]viewplaincopydockerrun-iubuntu/bin/bash-c'cat>/path/to/container/file'bash-c'cat>/path/to/container/file'
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询