docker在CentOs7启动失败和使用Navicat连接CentOs7Docker的MYSQL出现1251

分析 Docker 空间分布

Docker 的内置 CLI 指令docker system df,可用于查询镜像(Images)、容器(Containers)和本地卷(Local Volumes)等空间使用大户的空间占用情况。

docker在CentOs7启动失败和使用Navicat连接CentOs7Docker的MYSQL出现1251_第1张图片

可以进一步通过-v参数查看空间占用细节,以确定具体是哪个镜像、容器或本地卷占用了过高空间。

docker在CentOs7启动失败和使用Navicat连接CentOs7Docker的MYSQL出现1251_第2张图片

自动清理

可以通过 Docker 内置的 CLI 指令docker system prune来进行自动空间清理。

Docker之WARNING: IPv4 forwarding is disabled. Networking will not work.

vim /etc/sysctl.conf

#配置转发
net.ipv4.ip_forward=1

#重启服务,让配置生效
systemctl restart network

#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功

sysctl net.ipv4.ip_forward
 

docker在CentOs7启动失败的情况和原因--解决方案:

could not change group /var/run/docker.sock to docker: gr... not found

如果出现:Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

可执行systemctl status docker.service查看具体出错原因进行相关搜索。

在使用systemctl start docker启动失败时,使用systemctl status docker.service其报告如下:

docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-04-27 02:38:36 EDT; 12s ago
Docs: http://docs.docker.com
Process: 2356 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current 
--default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current
 --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY
 $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 2356 (code=exited, status=1/FAILURE)
 
Apr 27 02:38:35 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Apr 27 02:38:35 localhost.localdomain dockerd-current[2356]: time="2018-04-27T02:38:35.166869440-04:00" level
=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
Apr 27 02:38:35 localhost.localdomain dockerd-current[2356]: time="2018-04-27T02:38:35.171487584-04:00" 
level=info msg="libcontainerd: new containerd process, pid: 2361"Apr 27 02:38:36 localhost.localdomain dockerd-current[2356]:
 Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel or disable selinux in docker
 (--selinux-enabled=false)Apr 27 02:38:36 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 27 02:38:36 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Apr 27 02:38:36 localhost.localdomain systemd[1]: Unit docker.service entered failed state.Apr 27 02:38:36 localhost.localdomain systemd[1]: docker.service failed.

 

 docker在CentOs7启动失败和使用Navicat连接CentOs7Docker的MYSQL出现1251_第3张图片

此处意思是linux的内核中的SELinux不支持 overlay2 graph driver ,解决方法有两个,要么启动一个新内核,要么就在docker里禁用selinux,–selinux-enabled=false, 

解决办法如下:

 

1.rm -rf /var/lib/docker/ #如果不删除这个文件夹可能会导致继续失败
 如此方法不能解决,可参考:https://segmentfault.com/q/1010000002392472?_ea=176528
2.vi /etc/sysconfig/docker

 使用Navicat连接CentOs7Docker的MYSQL出现1251

root@localhost 桌面]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                               NAMES
7c0ae18150da        mysql               "docker-entrypoint..."   9 hours ago         Up 2 seconds                0.0.0.0:3306->3306/tcp, 33060/tcp   mysql01
49074f451a0e        tomcat              "catalina.sh run"        12 hours ago        Exited (143) 11 hours ago                                       frosty_einstein
进入MySQL容器
[root@localhost 桌面]# docker exec -it 7c0ae18150da  bash
root@7c0ae18150da:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host      | user             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| %         | root             | caching_sha2_password | $A$005$uj
                                                                  iZu    Xi*`s    :|ZADxWTQ1KIv.m/frdQEMmhIHoByUcXzn571taJhaaoP3 |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | caching_sha2_password | $A$005$ +-----------+------------------+-----------------------+------------------------------------------------------------------------+
5 rows in set (0.01 sec)

备注:host为 % 表示不限制ip   localhost表示本机使用    plugin非mysql_native_password 则需要修改密码

navicat链接错误;我们继续往下看;

mysql>  ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; 这里我们修改下密码
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;   //刷新
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,plugin,authentication_string from mysql.user; //刷新权限
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host      | user             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| %         | root             | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9                              |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | caching_sha2_password | $A$005$ +-----------+------------------+-----------------------+------------------------------------------------------------------------+
5 rows in set (0.00 sec)

之后就解决了这个问题
--------------------- 
    转载自 程序小强哥

 

docker es 设置运存和启动 端口映射

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 93
00:9300 --name ES01 5acf0e8da90b

docker run -p 6379:6379 -v $PWD/data:/data  -d redis:3.2 redis-server --appendonly yes

你可能感兴趣的:(dcoker,centenos7)