problem analysis
First of all, the container has been used before, and there is no problem with the network. I still use the fixed ip in the container, so the problem must appear later, and the container itself has not been changed.
Solution
If you are like me, the docker container suddenly cannot access the Internet, including the external network inside the container, and the host can not access the container, so the following methods must be used.
Will teach you a way you can, delete docker ifconfig network segment that appears, use the command sudo ifconfig br-91c937688b4a down
which br-91c937688b4a
is a ifconfig
view of the command network segment, so it can be stopped, and then restart the container.
Can refer to minedocker-compose
version: '2'
services:
hadoop-mysql:
#构建mysql镜像
image: hoult/mysql:5.7
container_name: hadoop-mysql # 容器名
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
privileged: true
environment:
MYSQL_ROOT_PASSWORD: 123456 #root管理员用户密码
MYSQL_USER: bigdata #创建bigdata用户
MYSQL_PASSWORD: 123456 #设置bigdata用户的密码
networks:
zoo:
ipv4_address: 172.18.0.5
ports:
- '3306:3306' #host物理直接映射端口为6606
volumes:
#mysql数据库挂载到host物理机目录
- ~/DockData/mysql/data/db:/var/lib/mysql
# 器的配置目录挂载到host物理机目录
- ~/DockData/mysql/data/conf:/etc/mysql/conf.d
#容器的日志目录挂载到host物理机日志目录
- ~/DockData/mysql/logs:/logs
networks:
zoo:
ipam:
config:
- subnet: 172.18.0.0/16
gateway: 172.18.0.1
Wu Xie, Xiao San Ye, a little rookie in the background, big data, and artificial intelligence.
Please pay attention to more