docker安装
yum remove docker \
docker
-
client \
docker
-
client
-
latest \
docker
-
common \
docker
-
latest \
docker
-
latest
-
logrotate \
docker
-
logrotate \
docker
-
selinux \
docker
-
engine
-
selinux \
docker
-
engine
安装一些必要的系统工具:
yum install
-
y yum
-
utils device
-
mapper
-
persistent
-
data lvm2
添加软件源信息:
yum
-
config
-
manager
--
add
-
repo http
:
// mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存:
yum makecache fast
安装 Docker-ce:
yum
-
y install docker
-
ce
启动 Docker 后台服务
systemctl start docker
测试运行 hello-world
docker run hello
-
world
安装MySQL 5.7
[root@test7 ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
177e7ef0df69: Pull complete
cac25352c4c8: Pull complete
8585afabb40a: Pull complete
1e4af4996053: Pull complete
c326522894da: Pull complete
9020d6b6b171: Pull complete
55eb37ec6e5f: Pull complete
1a9d2f77e0e7: Pull complete
d7e648ad64aa: Pull complete
4120d828ea6b: Pull complete
3b39dc5451af: Pull complete
Digest: sha256:bf17a7109057494c45fba5aab7fc805ca00ac1eef638dfdd42b38d5a7190c9bb
Status: Downloaded newer image for mysql:5.7
[root@test7 ~]# docker images |grep mysql
mysql 5.7 ba7a93aae2a8 6 days ago 372MB
[root@test7 ~]# docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
28817765fe403acc78cfa28eea5622873497e0534d754507e3d72b377dc04114
命令说明:
-p 3306:3306
:将容器的 3306 端口映射到主机的 3306 端口。
-v -v $PWD/conf:/etc/mysql/conf.d
:将主机当前目录下的 conf/my.cnf 挂载到容器的 /etc/mysql/my.cnf。
-v $PWD/logs:/logs
:将主机当前目录下的 logs 目录挂载到容器的 /logs。
-v $PWD/data:/var/lib/mysql
:将主机当前目录下的data目录挂载到容器的 /var/lib/mysql 。
-e MYSQL_ROOT_PASSWORD=123456:
初始化 root 用户的密码。
[root@test7 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
28817765fe40 mysql:5.7 "docker-entrypoint.s鈥 50 seconds ago Up 48 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp mymysql
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/543979/viewspace-2563709/,如需转载,请注明出处,否则将追究法律责任。