docker run --name <name> -v /etc/localtime:/etc/localtime:ro ....
解决方法二: 把时区设置加入到Dockerfile中
1 2 3 4
# CentOS RUN echo"Asia/shanghai" > /etc/timezone; # Ubuntu RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
特殊镜像的时区,如alpine 在解决方法一或二中加入一下命令
1
apk add -U tzdata
7. volume权限问题
执行命令的时候加入-u [当前linux用户名]
1
docke -run -u root ....
8. docker容器无法通过IP访问宿主机:No route to host
centos 7
查询docker0网卡ip
1 2 3 4 5 6 7 8
ip addr |grep docker0
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 32: veth3adebab@if31: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 48: veth7c11510@if47: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 353: vethc143d81@if352: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 423: veth5b7bcdf@if422: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
<?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> <servicename="ssh"/> <servicename="dhcpv6-client"/> <rulefamily="ipv4"> <sourceaddress="172.17.0.0/16" /> <accept /> </rule> </zone>
Error response from daemon: container ebd41f555dc1f027eb76eb74ecd14f803a07bbacd2cb9bc4ee1143fa68e90c66: driver "btrfs" failed to remove root filesystem: Failed to destroy btrfs snapshot /volume1/@docker/btrfs/subvolumes for 78f48d4542b189e1b2603fd4d55cb3a2fcb091bc76f3a5023e7bcf33baeac1ba: device or resource busy