系统版本
debian8.0
1、部署docker环境
- 配置并更新源,使用aptitude安装
deb http://mirrors.ustc.edu.cn/debian jessie main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian jessie main contrib non-free
deb http://mirrors.ustc.edu.cn/debian jessie-proposed-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian jessie-proposed-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian jessie-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian jessie-updates main contrib non-free
deb [arch=amd64] https://download.docker.com/linux/debian jessie stable
- 配置Docker加速器
编辑配置文件
root@linux:~# vim /etc/default/docker
添加
DOCKER_OPTS="–insecure-registry $DOCKER_OPTS --insecure-registry registry.mirrors.aliyuncs.com"
重启dokcer服务
root@linux:~# systemctl restart docker
- 直接使用安装包安装,相关包位置:172.16.0.200:/opt/package,根据提示安装相关依赖包,涉及的安装包如下:
├── aufs-tools_1%3a3.2+20130722-1.1_amd64.deb
├── cgroupfs-mount_1.1_all.deb
├── docker-ce_18.06.0~ce~3-0~debian_amd64.deb
├── git_1%3a2.1.4-2.1+deb8u6_amd64.deb
├── git-man_1%3a2.1.4-2.1+deb8u6_all.deb
├── libclass-accessor-perl_0.34-1_all.deb
├── libcwidget3_0.5.17-2_amd64.deb
├── libio-string-perl_1.08-3_all.deb
├── libnih1_1.0.3-4.3_amd64.deb
├── libnih-dbus1_1.0.3-4.3_amd64.deb
├── libparse-debianchangelog-perl_1.2.0-1.1_all.deb
├── libseccomp2_2.1.1-1_amd64.deb
├── libsub-name-perl_0.12-1_amd64.deb
├── makedev_2.3.1-93_all.deb
├── mountall_2.54_amd64.deb
├── mysql-client-5.5_5.5.60-0+deb8u1_amd64.deb
├── mysql-client_5.5.60-0+deb8u1_all.deb
├── mysql-common_5.5.60-0+deb8u1_all.deb
├── pigz_2.3.1-2_amd64.deb
├── plymouth_0.9.0-9_amd64.deb
├── python3-apt_0.9.3.12_amd64.deb
├── python3-dbus_1.2.0-2+b3_amd64.deb
├── python3-gi_3.14.0-1_amd64.deb
├── python3-software-properties_0.92.25debian1_all.deb
├── software-properties-common_0.92.25debian1_all.deb
├── tor_0.2.5.14-1_amd64.deb
└── unattended-upgrades_0.83.3.2+deb8u1_all.deb
2、部署mysql 5.7
- mysql版本:5.7
使用docker下载mysql5.7 images:
root@linx:~# docker pull mysql:5.7
Using default tag: latest
latest: Pulling from library/mysql
be8881be8156: Pull complete
c3995dabd1d7: Pull complete
9931fdda3586: Pull complete
bb1b6b6eff6a: Pull complete
a65f125fa718: Pull complete
2d9f8dd09be2: Pull complete
37b912cb2afe: Pull complete
54242fcd8eaa: Pull complete
0a9d4d211511: Pull complete
270ae5bd02c2: Pull complete
9b55b8e72e70: Pull complete
68083f7985cd: Pull complete
Digest: sha256:e42cbb3afa80aa210aa1245b930619c12641a8de57a486e6f1b11858307bd378
Status: Downloaded newer image for mysql:latest
- 启动mysql
root@linx:/data/mysql# docker run -d -p 3306:3306 -v /data/mysql/conf/:/etc/mysql -v /data/mysql/data-v5.7:/var/lib/mysql -v /data/mysql/add/:/opt/add -e MYSQL_ROOT_PASSWORD=R0ck9 --name mysqlv5.7 mysql:5.7
OPTIONS说明:
-d: 后台运行容器,并返回容器ID;
-p: 端口映射
--name="nginx-lb": 为容器指定一个名称;
-e username="ritchie": 设置环境变量;
- 容器查询
root@nextcloud:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d1a49bf5bf7b mysql:5.7 "docker-entrypoint.s…" 41 hours ago Up 4 hours 0.0.0.0:3306->3306/tcp mysqlv5.7
- 设置mysql远程连接
root@nextcloud:~# mysql -uroot -p
Server version: 5.7.23 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.
root@linux:~# mysql> create database nextcloud;
Query OK, 1 row affected (0.00 sec)
root@linux:~# mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
root@linux:~# mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
修改mysql登录密码
root@linux:~# mysql> alter user 'root'@'%'identified by 'rockyrocky';
Query OK, 0 rows affected (0.01 sec)
root@linux:~# mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
3、nextcloud
-
使用docker pull nextcloud下载最新的nextcloud images,同mysql
-
启动nextcloud镜像
root@linx:/data/nextcloud# docker run -d -p 80:80 -v /data/nextcloud/data/:/var/www/html/data -v /data/nextcloud/add/:/opt/add --name nextcloud-mysqlv5.7 --link mysqlv5.7 nextcloud
779071bb2789d19799a6e74a62cc2f1b02f2bf644d7330cb549e8ba1bf98585f
- 查看容器
root@linx:/data/nextcloud# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
779071bb2789 nextcloud "/entrypoint.sh apac…" 4 seconds ago Up 3 seconds 0.0.0.0:80->80/tcp nextcloud-mysqlv5.7
d1a49bf5bf7b mysql:5.7 "docker-entrypoint.s…" 18 minutes ago Up 18 minutes 0.0.0.0:3306->3306/tcp mysqlv5.7
- 进入容器
root@linux:~#docker exec -it 779071bb2789 bash
4、 修改之后提交images
- 在对docker中的应用配置进行修改之后,docker不会自动提交,需要使用docker commit命令来提交成新的images,以免当前运行的iamges出现问题之后导致数据或者配置丢失。
root@linux:~#docker ps 查看container_id
root@linux:~#docker commit container_id [new_images_name:tag ]
options:
-a, --author="" Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
-m, --message="" Commit message
- 如果需要使用新提交的images启动 命令docker run,具体见启动mysql nextcloud镜像,需要修改映射端口,也可以将已经运行的容器停止并删除,使用原来的启动命令,不需要任何修改
5、 常见问题
- 迁移或者回滚之后nextcloud跳到创建管理员账户界面,由于数据库中已经创建过管理员用户,目前可尝试将数据库nextcloud中表oc_users中管理员用户删除的方法,来重建管理员账户跳过创建管理员用户页:
root@linux:~# mysql> delete from oc_users where uid = 'admin';
网友评论