#安裝docker
[root@VM_0_10_centos ~]# yum install docker
[root@VM_0_10_centos ~]# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@VM_0_10_centos ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@VM_0_10_centos ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64
Go version: go1.10.3
Git commit: b2f74b2/1.13.1
Built: Wed May 1 14:55:20 2019
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64
Go version: go1.10.3
Git commit: b2f74b2/1.13.1
Built: Wed May 1 14:55:20 2019
OS/Arch: linux/amd64
Experimental: false
[root@VM_0_10_centos ~]# docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... 8115 [OK]
docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 2753 [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 607 [OK]
docker.io docker.io/zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 191 [OK]
docker.io docker.io/hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 113
......
[root@VM_0_10_centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@VM_0_10_centos ~]# docker pull mysql:5.6
Trying to pull repository docker.io/library/mysql ...
5.6: Pulling from docker.io/library/mysql
743f2d6c1f65: Pull complete
3f0c413ee255: Pull complete
aef1ef8f1aac: Pull complete
f9ee573e34cb: Pull complete
3f237e01f153: Pull complete
c834d5397c17: Pull complete
167b4b0bb213: Pull complete
8e13de731ad8: Pull complete
0dcd497f8ff9: Pull complete
82d36065c763: Pull complete
f30363b0dfa6: Pull complete
Digest: sha256:8547945d0e59b747c768e9d2bec3629ee2699837705457c3350709219b8c6ff4
Status: Downloaded newer image for docker.io/mysql:5.6
[root@VM_0_10_centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.6 73829d7b6139 31 hours ago 256 MB
[root@VM_0_10_centos ~]# docker run -d -p 3306:3306 --name mymysql -e MYSQL_ROOT_PASSWORD=root docker.io/mysql:5.6
.....
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:235: starting container process caused "process_linux.go:258: applying cgroup configuration for process caused \"Cannot set property TasksAccounting, or unknown property.\"".
#解決:主要原因還是centos系統版本兼容性問題,如果將系統做更新升級,即可解決。
[root@VM_0_10_centos ~]#yum update
[root@VM_0_10_centos ~]# docker run -d -p 3306:3306 --name mymysql -e MYSQL_ROOT_PASSWORD=root docker.io/mysql:5.6
3dbd7dbce555ac14223144f12af7f6770ddc5fa3f67d1171f1e17de39b8d3369
[root@VM_0_10_centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3dbd7dbce555 docker.io/mysql:5.6 "docker-entrypoint..." 38 seconds ago Up 34 seconds 0.0.0.0:3306->3306/tcp mymysql
[root@VM_0_10_centos ~]# docker exec -it 3dbd7dbce555 bash
root@3dbd7dbce555:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.44 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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>
#上傳文件到docker容器
[root@server data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
73cfe9bb6fe6 docker.io/mysql:5.6 "docker-entrypoint..." 47 hours ago Up 5 hours 0.0.0.0:3306->3306/tcp mymysql
[root@server data]# docker cp db_cis_227.sql 73cfe9bb6fe6:/root/
#
[root@server data]# docker exec -it 73cfe9bb6fe6 bash
root@73cfe9bb6fe6:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.6.44 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> source /root/dby_227.sql
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema | |
| mysql |
| performance_schema |
+--------------------+
6 rows in set (0.00 sec)