背景
在作测试的时候,遇到一个问题,docker 跑起来了,配置呀,数据导入呀都搞好了,突然发现:
- 端口没有作映射
- mysql5.7后 only_full_group_by 报错,mysql的数据卷映射没有做
…
环境
注意 wsl2 ,不然可能docker都跑不起来
- wls2
- ubuntu20.04
修改 yshop-redis 在docker启动后可以自动启动
- 查看下对应的 container
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
da3f2e1a943d redis "docker-entrypoint.s…" 22 hours ago Exited (0) 10 minutes ago yshop-redis
- 停止对应的container
docker stop da3f2e1a943d
- 编辑对应的container 配置文件
注意 /var/lib/docker/containers 这个文件夹就是容器文件
vim /var/lib/docker/containers/da3f2e1a943da9c5ec282283544bd8f144148a925eb5275bf95bb283d440426a/hostconfig.json
文件内容:
{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"default","PortBindings":{"6379/tcp":[{"HostIp":"","HostPort":"6379"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"CapAdd":null,"CapDrop":null,"CgroupnsMode":"host","Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","ConsoleSize":[0,0],"Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteIOps":null,"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"KernelMemory":0,"KernelMemoryTCP":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/asound","/proc/acpi","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug","/proc/scsi","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]}
"RestartPolicy":{"Name":"no","MaximumRetryCount":0}
修改为
"RestartPolicy":{"Name":"always","MaximumRetryCount":0}
- 重启docker 服务
注意: wsl2 中貌似 使用 systemctl 会有问题,实际上,sytemctl 是 service 命令的升级,在日常中应尽量使用 systemctl(印象中是酱紫)。 文件修改后一定要重启docker服务
service docker restart
|