Docker快速部署ownCloud

Posted by 橙叶 on Fri, Jan 27, 2017
如前(Owncloud安装过程)所述,ownCloud安装涉及LAMP环境的搭建与调试,耗时比较长,本文介绍通过Docker快速部署ownCloud

安装Docker

Ubuntu:
sudo apt-get install docker.io
CentOS:
yum install docker.io
systemctl start docker
docker安装好后,基本上就可以直接开启下一步了,但是从Docker Hub拉取镜像非常慢,建议到Daocloud.io用个加速器。

部署

拉取ownCloud官方镜像

ownCloud的官方镜像页面:https://hub.docker.com/_/owncloud/

这个镜像已经集成了Apache+PHP环境

拉取:

docker pull owncloud
fikgreg@ubuntu:~$ sudo docker pull owncloud
Using default tag: latest
latest: Pulling from library/owncloud
5040bd298390: Pull complete 
568dce68541a: Pull complete 
6a832068e64c: Pull complete 
3b0f3d176a5b: Pull complete 
20cc248a5690: Pull complete 
6ff565538ee6: Pull complete 
9f1077228581: Pull complete 
57359f144a19: Pull complete 
9754ef36b033: Pull complete 
e156df35b624: Pull complete 
df09daa2224a: Pull complete 
bfa0d8031302: Pull complete 
fe629d500af7: Pull complete 
52c2ae1164f8: Pull complete 
525704f508e7: Pull complete 
b1a28620fc67: Pull complete 
99b61ffeedee: Pull complete 
6a31aeafa3b7: Pull complete 
24039cb3e142: Pull complete 
b0e5052ad41b: Pull complete 
Digest: sha256:6e48c832aa0354af0155e963f1ced0faf6e22d56f696ab489fc307a2bbf0fe0d
Status: Downloaded newer image for owncloud:latest #拉取完毕

如果你不是用root账户登录的话,很可能发生错误:

Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

在前面加上sudo获取root权限就好了······(之前被这个问题搞了好几次)

sudo docker pull owncloud
sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
owncloud            9.1                 2e5636e065e8        2 days ago          566.1 MB

 

启动镜像

启用8.1版本
sudo docker run -d -p 80:80 owncloud:8.1
或者启用最新的9.1版本
fikgreg@ubuntu:~$ sudo  docker run -d -p 80:80 owncloud:9.1
Unable to find image 'owncloud:9.1' locally
9.1: Pulling from library/owncloud
5040bd298390: Already exists 
568dce68541a: Already exists 
6a832068e64c: Already exists 
3b0f3d176a5b: Already exists 
20cc248a5690: Already exists 
6ff565538ee6: Already exists 
9f1077228581: Already exists 
57359f144a19: Already exists 
9754ef36b033: Already exists 
e156df35b624: Already exists 
df09daa2224a: Already exists 
bfa0d8031302: Already exists 
fe629d500af7: Already exists 
52c2ae1164f8: Already exists 
525704f508e7: Already exists 
b1a28620fc67: Already exists 
99b61ffeedee: Already exists 
6a31aeafa3b7: Already exists 
24039cb3e142: Already exists 
b0e5052ad41b: Already exists 
Digest: sha256:61ef6ae08f3a9dc33623f4c1c90fbfec753353ce9a9ba6467d56664e2c048c22
Status: Downloaded newer image for owncloud:9.1
ff6332e641685c04ba0896dff0f3143caa8ab997a46b486e091dafda22af3d0a
在浏览器里输入http://你的服务器ip

现在,直接设置用户名和密码,然后点击“安装完成“就可以使用ownCloud了,这样数据库使用的是SQLite。

P.S.

如果要使用MySQL作为数据库,那么你需要先运行一个MySQL容器,启动镜像的命令后加上--link my-mysql:mysql连接mysql容器

创建MySQL容器

拉取:
sudo docker pull mysql

Using default tag: latest latest: Pulling from library/mysql 5040bd298390: Already exists 55370df68315: Pull complete fad5195d69cc: Pull complete a1034a5fbbfc: Pull complete 84bedc72ed3a: Pull complete 10981627b57d: Pull complete 0eb1485c660d: Pull complete e3ee110bb981: Downloading 16.93 MB/76.98 MB 01dd88d2ce4f: Download complete a08baf9a1c89: Download complete 2f844a59fb03: Download complete

启用:

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=密码 -d mysql:5.7
docker run --name owncloud --link some-mysql:mysql -d application-that-uses-mysql

 



comments powered by Disqus